Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old September 27th, 2008, 02:15 PM
vinodkus@gmail.com
Guest
 
Posts: n/a
Default set default value

dear sir/madam
what is the syntex for changing default value.
table name is test
uno numeric(9)
name1 char(10)
address char(10)

default value of addres is set to 'delhi'

i have to change it to 'patna'

please give me query for it

thanks in advance
  #2  
Old September 27th, 2008, 03:55 PM
Dan Guzman
Guest
 
Posts: n/a
Default Re: set default value

what is the syntex for changing default value.
Quote:
table name is test
uno numeric(9)
name1 char(10)
address char(10)
>
default value of addres is set to 'delhi'
>
i have to change it to 'patna'
You first need the constraint name. This can be found with:

EXEC sp_helpconstraint 'dbo.'test'

You can then drop and recreate the constraint by name with a script like the
example below. Just substitute the actual constraint name.

ALTER TABLE dbo.test
DROP CONSTRAINT DF_test_address

ALTER TABLE dbo.test
ADD CONSTRAINT DF_test_address
DEFAULT ('patna') FOR address

--
Hope this helps.

Dan Guzman
SQL Server MVP
http://weblogs.sqlteam.com/dang/

 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles