I need to find out which table (name) a particular constraint belongs to.
Does anyone have any TSQL to achieve this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
many things could be considered to be a constraint:
primary key
foreign key
unique index
check constraint
column default
your question is a little vague. Do you know the name of the constraint, the type, etc.?
Based on the limited info in your question. I suggest that you look at the source code to the master.sys.sp_helpconstraint stored procedure.
In Sql Server Management Studio, using the Object Explorer, ust navigate to: “Databases” – “System Databases” – “master” – “Programmability” – “Stored Procedures” – “System Stored Procedures” – “sys.sp_helpconstraint”. It contains all the tsql to query all the various kinds of constraints.