select a.*
FROM syscolumns a
inner join sysobjects b
on a.id=b.id and b.xtype='U'
and b.name<>'dtproperties'
where exists(SELECT 1
FROM sysobjects
where xtype='PK'
and name in (
SELECT name
FROM sysindexes
WHERE indid in(
SELECT indid
FROM sysindexkeys
WHERE id = a.id
AND colid=a.colid
)
)
)
and b.name='_TableName'
FROM syscolumns a
inner join sysobjects b
on a.id=b.id and b.xtype='U'
and b.name<>'dtproperties'
where exists(SELECT 1
FROM sysobjects
where xtype='PK'
and name in (
SELECT name
FROM sysindexes
WHERE indid in(
SELECT indid
FROM sysindexkeys
WHERE id = a.id
AND colid=a.colid
)
)
)
and b.name='_TableName'