By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,677 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

How to obtain constraint (key) info

P: n/a
i need to programmatically obtain and process constraint key
information. the problem with the output from sp_helpconstraint is
that it outputs 2, and sometimes 3 resultsets. (the 2nd
resultset/constraint_keys is exactly what i need however)

because the resultsets vary in output format, i cannot programmatically
use the output to process in my DB proc. its essentially useless to
me. i can only suppress the 1st resultset (with tablename info), and
cannot suppress the occasional 3rd resultset (that has referencing
foreign key info).

i've tried to directly access all kinds of sytem tables but i'm not
getting the complete info that the 2nd resultset that
sp_helpconstraints offers.

any suggestions? thanks.

Aug 7 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
(dj********@yahoo.com) writes:
i need to programmatically obtain and process constraint key
information. the problem with the output from sp_helpconstraint is
that it outputs 2, and sometimes 3 resultsets. (the 2nd
resultset/constraint_keys is exactly what i need however)

because the resultsets vary in output format, i cannot programmatically
use the output to process in my DB proc. its essentially useless to
me. i can only suppress the 1st resultset (with tablename info), and
cannot suppress the occasional 3rd resultset (that has referencing
foreign key info).

i've tried to directly access all kinds of sytem tables but i'm not
getting the complete info that the 2nd resultset that
sp_helpconstraints offers.

any suggestions? thanks.


I would use the Object Browser in Query Analyzer to find the procedure
and script it, and the steal the goodies that I need. I can guess
that the code is not really for the faint of heart, but if you are
wholly satisfied with that second resultset, modifying the code to
not display the foreign keys should not be difficult.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Aug 7 '05 #2

P: n/a
works like a charm, smart and simple. thanks.

Aug 8 '05 #3

P: n/a
Try these also

Sp_pkeys 'tablename'
and
Sp_Fkeys 'tablename'

Madhivanan

Aug 8 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.