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
 SQL Server Development (2000)
 List of constraints

Author  Topic 

swarna
Starting Member

6 Posts

Posted - 2005-08-22 : 01:34:18
How can i get the list of constraints for a particular schema.

I gave this query
String s = "SELECT cols.name, c_obj.name ,t_obj.name FROM sysobjects t_obj, sysobjects c_obj, syscolumns cols WHERE t_obj.name = 'checkpr' AND cols.id = t_obj.id AND c_obj.id = cols.cdefault AND c_obj.xtype = 'D'";

This gives me the list of default constraints for all the schemas which has the table name as 'checkpr'.

I need to list of default constraints for a particular schema only.

Experts!!Please help me as i can go further in my project only when i can solve this.

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2005-08-22 : 04:20:02
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_2j1v.asp
Go to Top of Page

swarna
Starting Member

6 Posts

Posted - 2005-08-22 : 04:38:04
quote:
Originally posted by LarsG

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_2j1v.asp




Thanks for replying. But "TABLE_CONSTRAINTS" does not include the default constraints.That is the problemn.
I need to list the default constraints for a particular schema.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 05:34:50
Try this

Select table_name,column_name from information_schema.COLUMNS where column_default is not null


Madhivanan

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

swarna
Starting Member

6 Posts

Posted - 2005-08-22 : 06:04:59
quote:
Originally posted by madhivanan

Try this

Select table_name,column_name from information_schema.COLUMNS where column_default is not null


Madhivanan

Failing to plan is Planning to fail




sorry... but this does not give the name of the constraints.It give me the column names which has the default constraints
"How can i get the list of the default constraints for a particualar schema."
As I need to drop the constraints for that schema.
Go to Top of Page
   

- Advertisement -