昨天给客户导数据,内容表38万条记录,表字段不到100个。用程序分批导。sql
因为标识列 id 里的值有用,因此在导入时把id改成了不自增。导完后,再加为自增列时,提示超时。数据库
用语句 alter table rcms_contents alter column [id] bigint identity(1,1) 修改,在sql08下提示语法错误。ide
因而找高手,上网查,解决了。方法以下:设计
一、先把数据加到临时表里,一下子会用到 select * into #content from contentit
二、先加一列id_1设为自增列 alter table rcms_Contents add id_1 bigint identity(1,1)table
三、(必定要备份数据库)而后把正表里的数据删掉 truncate table contentselect
四、打开此表设计,把id列改成自增,保存表语法
五、执行 set identity_insert content on (可更改标识列)程序
六、用 insert into 字段 select 字段 from #content 从临时表里进行导入数据方法
七、把可更改标识列的值关闭,执行 set identity_insert content off
其中第二步能够不执行
这样就大功告成了。数据库方面还要再增强。