首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教怎么用sql语句查看一个表的主键,请详细说一下,多谢

2012-03-12 
请问如何用sql语句查看一个表的主键,请详细说一下,谢谢如题[解决办法]select * from (select b.name as tb

请问如何用sql语句查看一个表的主键,请详细说一下,谢谢
如题

[解决办法]
select * from (
select b.name as tblname ,a.name as colname,
主键=case when 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
))) then '√ ' else ' ' end
from syscolumns a ,sysobjects b
where a.id=b.id and b.xtype= 'u ') aa
where 主键!= ' '

热点排行