把非自增的字段转换成自增字段
时间:2011-11-15
来源:互联网
有大量的表要转换,把非自增字段转为自增,并加主键
有没有这样的存储过程啊?
有没有这样的存储过程啊?
作者: aspwebchh 发布时间: 2011-11-15
没有
可用动态生成语句
如:
SQL code
可用动态生成语句
如:
SQL code
--删除主健 select 'alter table '+quotename(a.name)+' drop constraint ' +QUOTENAME(b.Name) from sys.objects as a inner join sys.objects as b on a.object_id=b.parent_object_id and b.type='PK' where not exists(select 1 from sys.columns where object_id=a.object_id and is_identity=1) and a.type='U' --新增标识列为主健,列名为ID,首先要定义好列名的唯1 select 'alter table '+quotename(name)+' add ID int identity(1,1) primary key' from sys.objects as a where not exists(select 1 from sys.columns where object_id=a.object_id and is_identity=1) and type='U'
作者: roy_88 发布时间: 2011-11-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28