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.
| Author |
Topic |
|
sandhyarao49
Starting Member
4 Posts |
Posted - 2008-10-05 : 20:15:33
|
| Hi,I have a small doubt.How to check the constraints(and constraints logic) defined on a particular table.Thanks,Sandhya |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-06 : 00:26:23
|
sp_help tablename will give you all constraint defined on table along with column details.or useselect * from sys.objects oleft join sys.key_constraints kc on kc.parent_object_id = o.object_idleft join sys.check_constraints cc on cc.parent_object_id = o.object_idleft join sys.default_constraints dc on dc.parent_object_id = o.object_idleft join sys.foreign_keys fk on fk.parent_object_id = o.object_idwhere OBJECT_NAME(o.object_id)=yourtablename |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-10-06 : 01:25:16
|
or use information_schema viewsselect ccu.COLUMN_NAME,ccu.CONSTRAINT_NAME,rc.CONSTRAINT_TYPE from information_schema.constraint_column_usage ccuINNER JOIN information_schema.TABLE_CONSTRAINTS rcON rc.CONSTRAINT_NAME=ccu.CONSTRAINT_NAMEwhere ccu.table_name='YourTableName' |
 |
|
|
|
|
|