-----------------------------------------------
SQL Server 2005 查詢ideneity
-----------------------------------------------
Use Northwind
select s.Name SchemaName,t.Name tableName,
case when c.NAME is null then 'N' else 'Y' END [是否有Identity],
c.NAME Ideneity欄位名稱
from sys.sysobjects t
left JOIN sys.identity_columns c ON object_id=id
JOIN sys.schemas s ON schema_id=uid
where Type='U'
-----------------------------------------------
SQL Server 2000 查詢ideneity
-----------------------------------------------
Use Northwind
select o.Name TableName,
case when c.NAME is null then 'N' else 'Y' END [是否有Identity],
c.Name Ideneity欄位名稱
from sysobjects o
left join (
select * from dbo.syscolumns c
where c.status=128
) c on c.ID=o.ID
where o.xType='U'
留言列表