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)
 How to check default value exists on a column?

Author  Topic 

matkwan
Starting Member

36 Posts

Posted - 2007-05-10 : 04:01:35
Hi,

Before I run this:
"ALTER TABLE [dbo].[ttClass] ADD DEFAULT (1) FOR [LearningAreaID]"

I would like to check if the default has already set to that column.

Any idea how?

Matt

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-05-10 : 04:05:03
[code]If Exists(select * from information_schema.columns where table_name = 'ttClass'
and column_name = 'LearningAreaID'
and Table_schema = 'dbo'
and column_default is NULL)
ALTER TABLE [dbo].[ttClass] ADD DEFAULT (1) FOR [LearningAreaID]
GO[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -