select *
from sysobjects
where xtype='pk' and
parent_obj in (select id from sysobjects where name='tablename')
Posted At : Sep 19, 2012 20:34 PM
| Posted By : Ed Tabara
Related Categories: SQL
Related Categories: 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:
| 33995 Views
| 39% / 0% Popularity
Comments