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
 Transact-SQL (2005)
 Gte the PRIMARY KEY FIELD from query

Author  Topic 

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-08-10 : 03:02:57
Hi all,

I have lot of sql server table in my application.. i want to get the primary key field in selected tables from programatically. so i need the query to get the primary key field in [articular table.

pls help me,

kamal

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-10 : 03:06:06
Here is a starter
SELECT	*
FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-08-10 : 03:08:06
fine, thanks...
Go to Top of Page

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2009-08-10 : 03:11:17
Try this too


SELECT *
FROM sys.objects where type='pk'

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

kamal.A
Yak Posting Veteran

70 Posts

Posted - 2009-08-10 : 04:38:40
thnx senthil..

Go to Top of Page
   

- Advertisement -