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 |
|
swarna
Starting Member
6 Posts |
Posted - 2005-09-08 : 04:53:29
|
| Hi, I want to get the column name of the unique constraint.I used sysobject and sysconstraint which gives me the list of uniqueconstraints but i dont have any info about which column has this unique constraint..."select * from sysconstraints " gives me "colid" as "0" for unique constraint which makes it difficult to retrieve the column name.Can anybody help me. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-08 : 05:02:20
|
| Try thisSelect t1.table_name,t2.Column_name from information_Schema.TABLE_CONSTRAINTS t1 inner join information_Schema.KEY_COLUMN_USAGE t2on t1.table_name=T2.table_name where Constraint_Type='Unique' you can also runsp_help 'yourTable'MadhivananFailing to plan is Planning to fail |
 |
|
|
swarna
Starting Member
6 Posts |
Posted - 2005-09-08 : 05:25:52
|
| great...This is working (but with some modifications)!!!!I wasted about 2 hours trying to get some solution for it..Now i feel i should have posted it much earlier itself:-))).Thank you very much. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-08 : 05:35:02
|
| Well>>This is working (but with some modifications)!!!!What modifications did you do?Did you supply tableName?MadhivananFailing to plan is Planning to fail |
 |
|
|
swarna
Starting Member
6 Posts |
Posted - 2005-09-08 : 05:48:36
|
| yupsupply table nameadded one more condition t1.constraint_name = t2.constraint_name as data was replicating.i dont know whether i made the correct approach but i am getting the results as i wanted. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-09-08 : 05:58:28
|
Yes. That seems good MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|