Thursday, September 20, 2012

How To Get Primary Key In MS SQL

How To Get Primary Key In MS SQL: Some time ago had a nightmare when trying to create Full-Text Index for a table with a "weird" name for the Primary Key. And because i did not have access to DB structure i had to find a way to get PKs info programmatically. So, for my later reference and for anyone that will have similar problems, here is the code to find the Primary Key name in MS SQL: select * from sysobjects where xtype='pk' and parent_obj in (select id from sysobjects where name='tablename')

DIGITAL JUICE

No comments:

Post a Comment

Thank's!