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.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Primary key information

Author  Topic 

Jude_Aj
Starting Member

22 Posts

Posted - 2009-10-28 : 07:08:08
Hi,
Can anybody tell me in which system table the primary key information is stored in sql server 2005.
In sql server 2000, I could find the primary key info of a particular table(if it exist) in sysobject system table.But i am clueless about sql server 2005 .

Thanks,

Jude


webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-10-28 : 07:18:23
You can use
sp_pkeys table_name


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2009-10-28 : 07:30:44
this works in 200, 2005, 2008
select * from INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE Constraint_Type = 'PRIMARY KEY'
can add WHERE table_name = 'YourTable' if looking for a particular table


this works in 2005+
select * from sys.indexes where is_primary_key = 1
Go to Top of Page

Jude_Aj
Starting Member

22 Posts

Posted - 2009-10-28 : 09:13:06
Thanks for replying.
Well i am not looking for a query that fetches primary key info.
I wanted the name of the system table (like sys.sysallocunits, sys.sysrowsets, sys.sysrowsetcolumns etc) that holds this information.


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-10-28 : 10:17:04
What is wrong with INFORMATION_SCHEMA.TABLE_CONSTRAINTS?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Jude_Aj
Starting Member

22 Posts

Posted - 2009-10-29 : 04:21:17
Hi,

is there any query that would give me the schema for
INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE system view
Go to Top of Page
   

- Advertisement -