Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find which field is the Primary key using SQL? 1

Status
Not open for further replies.

level1

Programmer
Apr 16, 2002
60
0
0
GB
Is there any way to find which filed is the unique ID field in a table by using some type of SQL... i.e:

select * from Test_Db..syscolumns c
join Test_Db..sysobjects o on c.id = o.id
where o.name = 'table_Test'

The above example will find all column names for a given table.

I m looking for something similar for quering which field is the Unique identifier in a table. By looking on the sysobjects etc of the SQL server 2000 looks like im lost for now.

anybody knows the answer Please help???
 
Take a look at this thread183-1049647

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
nice one thanks

"exec sp_pkeys table_Test"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top