Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Default value to column

Author  Topic 

shubhada
Posting Yak Master

117 Posts

Posted - 2006-08-29 : 04:45:14
I have table with column col1 numeric(8,1) null
I want to set default value to this column as 1
How I can set this value to col1 using query?


SQLTeam

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-29 : 04:51:29
[code]alter table t1 add constraint DF_t1_col1 DEFAULT 1 FOR col1[/code]


KH

Go to Top of Page

shubhada
Posting Yak Master

117 Posts

Posted - 2006-08-29 : 05:10:49
How I can check whether that column have default value or not ?

SQLTeam
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-08-29 : 05:16:52
[code]select COLUMN_DEFAULT from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME = 't1' and COLUMN_NAME = 'col1'[/code]


KH

Go to Top of Page

Pace
Constraint Violating Yak Guru

264 Posts

Posted - 2006-08-29 : 06:37:31
very useful, thanks ;-)

when life hands you lemons, ask for tequila and salt
Go to Top of Page
   

- Advertisement -