2008年7月14日 星期一

SQL 2000 Determine primary key from system table 列出所有Primary Key

select object_name(a.[id]) as [TableName]
,object_name(a.constid) as [PK_name]
,b.[name] as [PK_Column]
from sysconstraints a inner join syscolumns b
on a.[colid]+1 = b.[colid] and a.[id] = b.[id]
where a.status = 2593

PS. Status=2593還未找到確認的文件說明,另外覆合Key可能不適用

沒有留言: