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 2000 Forums
 SQL Server Development (2000)
 sql dmo with VB

Author  Topic 

1fred
Posting Yak Master

158 Posts

Posted - 2002-10-21 : 17:22:28
I'm looking a way to retrieve my primary key from a table with sql-dmo or other methods in VB. It is easy if I had only a ID field, but sometimes 2 or 3 fields are making the primary key.

Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-10-21 : 17:32:24
You can do this with a simple ADO recordset by querying the INFORMATION_SCHEMA.KEY_COLUMN_USAGE view:

SELECT * FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME='myTable'


That's probably the easiest way to do it. See Books Online for more info on other INFORMATION_SCHEMA views.

Go to Top of Page
   

- Advertisement -