![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![ExpandedBlockStart.gif](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
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
=
'
表名
'