Connecting Tech Pros Worldwide Help | Site Map

set default value

vinodkus@gmail.com
Guest
 
Posts: n/a
#1: Sep 27 '08
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
Dan Guzman
Guest
 
Posts: n/a
#2: Sep 27 '08

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/

Closed Thread