SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 List of constraints
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

swarna
Starting Member

6 Posts

Posted - 08/22/2005 :  01:34:18  Show Profile  Reply with Quote
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

Sweden
284 Posts

Posted - 08/22/2005 :  04:20:02  Show Profile  Reply with Quote
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 - 08/22/2005 :  04:38:04  Show Profile  Reply with Quote
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

India
22755 Posts

Posted - 08/22/2005 :  05:34:50  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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 - 08/22/2005 :  06:04:59  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000