Checking if a culomn is a primary key with System Tables

This will return 1 if the column specified is a primary key. Works with SQL Server 2000.

You just have to replace MY_TABLE_NAME and CULOMN_NAME in whe query

from sysindexes ind,
sysindexkeys indkey,
sysobjects obj,
sysobjects obj2,
syscolumns col
where + indkey.indid = + ind.indid and = and = obj.parent_obj and = and
obj.parent_obj = and
obj.parent_obj = and
col.colid = indkey.colid and
obj.xtype = 'PK' and = 'MY_TABLE_NAME' and = 'CULOMN_NAME'

No comments: