SQL Server修改标识列方法 如自增列的批量化修改
来源:asp之家 时间:2012-06-06 19:42:35
通过界面设计上是能手工操作的,无法达到我批量修改几千台服务器。
因为此了一个脚本来批量执行。
环境:redgate + mssql 2008 r2
以下代码根据自己的业务稍做修改即使用。
代码如下:
--允许对系统表进行更新
exec sp_configure 'allow updates',1
reconfigure with override
GO
--取消标识列标记
update syscolumns set colstat = 0 where id = object_id('tablename') and colstat = 1
GO
--插入id=8001-8003的行
--恢复标识列标记
update syscolumns set colstat = 1 where id = object_id('tablename') and name = '标识列名称'
--重新设置标识的起始值
DBCC CHECKIDENT (表名称, RESEED, 10003)
--禁止对系统表进行更新
exec sp_configure 'allow updates',0
reconfigure with override
还有很多批量操作的知识,
如批量检查索引是否准确
字段的长度是否一致
作业是否运行结果一致
服务是否同时启动
……
都需要批量来处理。
可参考我其他的文章获取其他批量操作的方法。
标签:标识列,sql,server
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
FF和IE之间7个JavaScript的差异[译]
2009-05-04 18:19:00
asp连接SQL和Access数据代码(asp里的随机函数)
2013-06-01 20:26:06
轻松解决AJAX的中文乱码问题
2008-09-03 12:55:00
ORACLE8的分区管理
2010-07-30 13:18:00
一份ASP内存的释放的实验报告
2007-10-17 13:09:00
![](https://img.aspxhome.com/file/UploadPic/200710/17/2007101713177321s.gif)
MSSQL数据库还原图解教程
2009-01-12 17:58:00
![](https://img.aspxhome.com/file/UploadPic/20091/12/34_20071005121043_mq==-29s.jpg)
IE下绝对定位的元素不能响应鼠标的bug修正
2008-09-10 13:03:00
![](https://img.aspxhome.com/file/UploadPic/20089/10/20089101380482s.png)
正确认识MySQL对服务器端光标的限制
2008-12-03 15:52:00
SQL Server数据库搭建农村信息化的方案
2009-01-23 14:16:00
![](https://img.aspxhome.com/file/UploadPic/20091/2009131151251116.jpg)
将图片读入到Dom中,并将其存为xml文件
2008-09-04 11:24:00
WEB移动应用框架构想
2010-09-28 16:26:00
![](https://img.aspxhome.com/file/UploadPic/up/2010092816392186.gif)
Sql Server 2012 转换函数的比较(Cast、Convert和Parse)
2012-08-21 10:21:40
web前端页面性能优化
2009-08-15 12:31:00
Asp教程:Response对象
2007-10-01 18:08:00
响应浏览器地址栏#(hash/fragment)变化
2009-12-28 10:45:00
Mootools 1.2教程(19)——Tooltips
2008-12-25 13:26:00
CSS布局之浮动(二)三列浮动
2008-08-19 12:47:00
ADSI+ASP添加IP到IIS禁止访问列表中
2011-04-02 10:42:00
MySQL Server 5.0安装教程(图解)
2010-10-14 14:26:00
![](https://img.aspxhome.com/file/UploadPic/201010/14/20101014143531281s.jpg)
说说tab设计
2009-07-26 09:56:00
![](https://img.aspxhome.com/file/UploadPic/20097/26/tab-yahoo-63s.jpg)