代码
Select
PrimaryKey
=
a.name
FROM
syscolumns a
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
=
'
表名
'