Hello,
If anyone can help me I will be forever grateful :-)
In MSSQL, I have table 'x'...
I need a query that will show all of the tables and primary keys that
table 'x' has relationships with.
so..say table 'x' has the following columns
x
--
id (PK)
table1FK (FK to 'table1')
table2FK (FK to 'table2')
dummy
and I have...
table1 table2
-- --
id (PK) id (PK)
dummy dummy
The pseudo query is...
SELECT table_name, primary_key
FROM system_tables
WHERE original_table = 'x';
please please help!
thanks so much..
-JayHi Jason,
Check sp_foreignkeys in Books Online.
--
Jacco Schalkwijk
SQL Server MVP
"Jason Baldwin" <jaybald@.yahoo.com> wrote in message
news:5a4fce6c.0310080733.4811a11d@.posting.google.com...
> Hello,
> If anyone can help me I will be forever grateful :-)
> In MSSQL, I have table 'x'...
> I need a query that will show all of the tables and primary keys that
> table 'x' has relationships with.
> so..say table 'x' has the following columns
> x
> --
> id (PK)
> table1FK (FK to 'table1')
> table2FK (FK to 'table2')
> dummy
> and I have...
> table1 table2
> -- --
> id (PK) id (PK)
> dummy dummy
>
> The pseudo query is...
> SELECT table_name, primary_key
> FROM system_tables
> WHERE original_table = 'x';
>
> please please help!
> thanks so much..
> -Jay
No comments:
Post a Comment