2008年7月14日 星期一

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

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可能不適用

沒有留言:

SQL Server Database Mirroring 資料庫鏡像

SQL Server Database Mirroring 資料庫鏡像