views:

3

answers:

1

Hi friends, I am working Sql Server 2005 My table name is Customer, the attributes are

Orderid Customerid Customeraddress

Wherein Customerid is the primary key and Orderid is the foreign key.

I want to know the primary key name, foreign key name and the table name where the foreign key exists as a primary key

Is there any query to retrieve those names using a table name? Kindly please provide me the queries...Thanks in advance

A: 

--list all columns in BLAH table select c.name from sys.columns c, sys.tables t where c.object_id=t.object_id and t.name='BLAH'

PerlDev