SQL Server修改标识列方法 如自增列的批量化修改
时间:2024-01-19 04:59:22
通过界面设计上是能手工操作的,无法达到我批量修改几千台服务器。
因为此了一个脚本来批量执行。
环境: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
还有很多批量操作的知识,
如批量检查索引是否准确
字段的长度是否一致
作业是否运行结果一致
服务是否同时启动
……
都需要批量来处理。
可参考我其他的文章获取其他批量操作的方法。
标签:标识列
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
vue使用iframe嵌入网页的示例代码
2024-05-05 09:12:04
以SQLite和PySqlite为例来学习Python DB API
2023-07-13 02:19:14
![](https://img.aspxhome.com/file/2023/2/60512_0s.png)
一文详解Golang协程调度器scheduler
2024-04-30 10:05:58
![](https://img.aspxhome.com/file/2023/5/130695_0s.png)
一篇文章带你搞定Ubuntu中打开Pycharm总是卡顿崩溃
2023-03-02 15:46:48
![](https://img.aspxhome.com/file/2023/1/94041_0s.png)
Go http client 连接池不复用的问题
2024-02-03 05:17:15
Pycharm安装第三方库失败解决方案
2021-10-09 07:01:39
![](https://img.aspxhome.com/file/2023/5/103275_0s.png)
mysql 5.7.18 zip版安装配置方法图文教程(win7)
2024-01-26 17:58:18
![](https://img.aspxhome.com/file/2023/0/104420_0s.png)
python实现定时发送qq消息
2021-08-17 00:10:34
![](https://img.aspxhome.com/file/2023/1/109501_0s.jpg)
MySQL判别InnoDB表是独立表空间还是共享表空间的方法详解
2024-01-18 14:23:34
![](https://img.aspxhome.com/file/2023/7/69177_0s.jpg)
SQL Server 自动增长清零的方法
2012-01-05 19:07:47
python获取全国城市pm2.5、臭氧等空气质量过程解析
2023-06-04 21:46:07
OpenCV-Python实现图像平滑处理操作
2021-06-19 10:28:21
![](https://img.aspxhome.com/file/2023/4/88924_0s.png)
M1芯片Mac上Anaconda的暂时替代(miniforge)
2022-12-12 00:32:43
![](https://img.aspxhome.com/file/2023/2/93872_0s.jpg)
解决Python3用PIL的ImageFont输出中文乱码的问题
2022-09-09 04:49:22
![](https://img.aspxhome.com/file/2023/2/105572_0s.jpg)
Python简单遍历字典及删除元素的方法
2021-12-31 08:57:51
Python-OpenCV基本操作方法详解
2021-11-25 20:40:01
![](https://img.aspxhome.com/file/2023/9/133479_0s.jpg)
tp5递归 无限级分类详解
2024-05-11 09:53:48
SQL语句练习实例之三——平均销售等待时间
2011-10-24 20:11:47
Go处理JSON数据的实现
2024-02-23 07:44:42
Vue中使用Teleport的方法示例
2024-05-09 15:13:19
![](https://img.aspxhome.com/file/2023/8/126548_0s.jpg)