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 |
|
Brent555
Starting Member
10 Posts |
Posted - 2006-05-12 : 00:08:47
|
| hey i was just wondering how to display the constraints from a particular table and display all the constraints and wat columns they apply to, someone told me they keyword u use but didnt tell me how to use it :P |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-12 : 00:18:41
|
[code]select c.name as column_name, object_name(constid) as constraint_namefrom syscolumns c inner join sysconstraints s on c.id = s.id and c.colid = s.colidwhere c.id = object_id('table_name')[/code] KH |
 |
|
|
Brent555
Starting Member
10 Posts |
Posted - 2006-05-12 : 00:29:21
|
| well i dont totally understand :P but im sure ill get it :Pthnx |
 |
|
|
Brent555
Starting Member
10 Posts |
Posted - 2006-05-12 : 00:44:03
|
| nah i cant get it, Its only displaying 1 constraintwat i wanna do is display all the constraints that act on two particular tables aswell as the type and i wanna display the column names that are being acted upon by all constraints over all the tables,maybe u can explain it to me |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-12 : 02:23:13
|
table sysconstraints contains constraints of an object. For type of constraints, refer to Books On Line on sysconstraints.column status will identify the typequote: Bitmap indicating the status. Possible values include: 1 = PRIMARY KEY constraint.2 = UNIQUE KEY constraint.3 = FOREIGN KEY constraint.4 = CHECK constraint.5 = DEFAULT constraint.16 = Column-level constraint.32 = Table-level constraint.
KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-12 : 02:36:25
|
| Also refer INFORMATION_SCHEMA.TABLE_CONSTRAINTS viewselect * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS where table_name='yourTable'MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|