日期:2014-05-17 浏览次数:20472 次
SELECT OBJECT_NAME(parent_obj) tname , a.name AS indexname,b.name as columnname FROM sys.sysobjects a inner join sys.syscolumns b on a.parent_obj=b.id WHERE a.xtype IN ( 'pk', 'uq' ) AND OBJECT_NAME(parent_obj) = '表名' and b.name='列名'
------解决方案--------------------
SELECT OBJECT_NAME(parent_obj) tname , a.name AS indexname , b.name AS columnname FROM sys.sysobjects a INNER JOIN sys.syscolumns b ON a.parent_obj = b.id WHERE a.xtype IN ( 'pk', 'uq' ) AND OBJECT_NAME(parent_obj) IN ( SELECT DISTINCT name FROM sys.tables )--and b.name='列名'