在对已经建好表结构的表抽取数据的时候,突然报错,根据Error发现,不能显式插入有自增列的值. 于是搜索后,用 set IDENTITY_INSERT #Tmp onset IDENTITY_INSERT #Tmp off 把自增列关闭再差,就ok了,附上代码 create table #Tmp (id ,),id_1 int) ,)--Error set IDENTITY_INSERT #Tmp on ,)--ok set IDENTITY_INSERT #Tmp off…
SQL语句获取数据库中的表主键,自增列,所有列 获取表主键 1:SELECT TABLE_NAME,COLUMN_NAME FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGEWHERE TABLE_NAME<>'dtproperties' 2:EXEC sp_pkeys @table_name='表名' 3: select o.name as 表名,c.name as 字段名,k.colid as 字段序号,k.keyno as 索引顺序,t.name as…