Connecting Tech Pros Worldwide Help | Site Map

set default value

  #1  
Old September 27th, 2008, 02:15 PM
vinodkus@gmail.com
Guest
 
Posts: n/a
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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set default value for a datetime column in mssql pks83 answers 2 February 6th, 2008 11:52 AM
Set default value to 1/1/current year Jimmy answers 5 December 23rd, 2006 12:15 AM
set default value for a char column?? tlyczko answers 7 September 26th, 2006 08:35 PM
Unable to set Default value for UserControl property Atchoum answers 5 November 20th, 2005 11:33 PM