日期:2014-05-17 浏览次数:20628 次
select a.name,a.is_identity
from sys.columns a inner join sys.objects b on a.object_id=b.object_id
where b.name='table' and a.name='column'
2. select * from sys.identity_columns where object_id = object_id('Sales.SalesOrderDetail')
1. select COLUMN_NAME,* from INFORMATION_SCHEMA.TABLE_CONSTRAINTS A
JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE B ON A.CONSTRAINT_NAME = B.CONSTRAINT_NAME
WHERE A.CONSTRAINT_TYPE = 'PRIMARY KEY' AND A.TABLE_NAME = 'SalesOrderDetail'
select a.name,c.is_primary_key
from sys.columns a inner join sys.index_columns b on a.object_id=b.object_id and a.column_id=b.column_id
inner join sys.indexes c on a.object_id=c.object_id where a.object_id=object_id('table') and a.name='column'
if columnproperty(object_id('tableName'),'columnName','IsIdentity')=1
select '自增列'
else
select '不是自增列'