use northwind
go
select 自增列的列名=name, 自增列所在表名=object_name(id)
from syscolumns
where COLUMNPROPERTY(id,name,'IsIdentity')=1
go
select 自增列的列名=name, 自增列所在表名=object_name(id)
from syscolumns
where COLUMNPROPERTY(id,name,'IsIdentity')=1
Select OBJECTPROPERTY(OBJECT_ID('表名'),'TableHasIdentity')
如果有,则返回1,否则返回0
如果为null,证明表没有设置自增字段 sql建立:create table test(sn int identiy(1,1))在SQL企业管理器中能设置吗,就是设置字段的identity属性为yes,其他就看你的需求!
参数一:表的id
参数二:表的字段
参数三:属性名,要用单引号引起