如何判断该列是否为主键?
在syscolumns表中,哪个列可以跟sys.objects这个表连接查询到syscolumns.name是否为主键?如果不行有什么其它的方法? --------------------编程问答-------------------- 不明白意思,帮你顶下 --------------------编程问答-------------------- 得到主键字段名1:
SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE TABLE_NAME<>'dtproperties'
2:
EXEC sp_pkeys @table_name='表名'
3:
select o.name as 表名,c.name as 字段名,k.colid as 字段序号,k.keyno as 索引顺序,t.name as 类型
from sysindexes i
join sysindexkeys k on i.id = k.id and i.indid = k.indid
join sysobjects o on i.id = o.id
join syscolumns c on i.id=c.id and k.colid = c.colid
join systypes t on c.xusertype=t.xusertype
where o.xtype = 'U'
and o.name='要查询的表名'
and exists(select 1 from sysobjects where xtype = 'PK' and parent_obj=i.id and name = i.name)
order by o.name,k.colid
--------------------编程问答-------------------- 神啊 写的是啥子咯
补充:.NET技术 , ASP.NET