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 2005 Forums
 Transact-SQL (2005)
 searching default data in systables

Author  Topic 

marginerazvan
Starting Member

14 Posts

Posted - 2007-11-12 : 07:32:45
I want to make a query that should list some informations about the columns that have defaults.

name of default constraint
name of the column
name of the table
value of default constraint

I cannot managed to know the last part (value of default constraint
)

Here is what I did until now:
select sysobjects.name, syscolumns.name, sysobjects_1.name from (sysobjects INNER JOIN sysobjects AS sysobjects_1 ON sysobjects.parent_obj = sysobjects_1.id)
inner join syscolumns on sysobjects.id = syscolumns.cdefault where sysobjects.xtype = 'D' and sysobjects_1.xtype = 'U'

Can you help me finding the exact VALUE of the default constraint?

Ex.
table name = OFFER_ARTICLES
column name = PIECES
default name = DF_PIECES
default value = 10

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-11-12 : 07:50:59
select column_name from INFORMATION_SCHEMA.COLUMNS
where column_default='((10))'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -