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 |
vishal_7
Posting Yak Master
127 Posts |
Posted - 2005-08-30 : 14:46:16
|
Hey, is it possible to get the relationship of a table via sql? Like I need to know which relations the table t has. Is that possible?Thanks |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-08-30 : 16:36:20
|
One way is from a query analyzer window: sp_help <tableName>Gives you a lot of info about the table including foreign Keys and tables referenced by foreign keys. (relationships are defined by foreign keys)Be One with the OptimizerTG |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-08-30 : 18:54:01
|
You can also try selecting from INFORMATION_SCHEMA.TABLE_CONSTRAINTS and INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS, these give you the same info as sp_help but in a different format. |
|
|
vishal_7
Posting Yak Master
127 Posts |
Posted - 2005-08-31 : 09:56:22
|
thanks guys, I will try it out and report when there are any probs. |
|
|
vishal_7
Posting Yak Master
127 Posts |
Posted - 2005-08-31 : 10:42:37
|
Isnt sp_fkeys much better for that purpose? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-31 : 10:46:23
|
Yes you can use sp_pkeys or sp_fkeys alsoMadhivananFailing to plan is Planning to fail |
|
|
|
|
|