最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
mssql中修改字段默认值default value
时间:2022-06-29 08:00:53 编辑:袖梨 来源:一聚教程网
1、取得数据库所有表的默认值:
代码如下 | 复制代码 |
t3.name as 表名,t1.name as 字段名,t2.text as 默认值 ,t4.name from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u’ and t3.id=t1.id and t4.xtype=’d’ and t4.id=t2.id; |
2、生成删除所有默认值的语句:
代码如下 | 复制代码 |
select “ALTER TABLE ” + t3.name + ” DROP CONSTRAINT ” +t4.name +”;” from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u' and t3.id=t1.id and t4.xtype=’d' and t4.id=t2.id ; |
3、生成批量添加所有默认值的语句:
代码如下 | 复制代码 |
select “alter table ” + t3.name + “ add default (1) for ” +t1.name +”;” from syscolumns t1,syscomments t2,sysobjects t3 ,sysobjects t4 where t1.cdefault=t2.id and t3.xtype=’u' and t3.id=t1.id and t4.xtype=’d' and t4.id=t2.id ; |
相关文章
- 我的新加密货币税收法案将终结不公平行为:参议员卢米斯 07-12
- 剑星活肤紧身服怎样进行获取呢 活肤紧身服收集方法介绍 07-12
- 原神伊涅芙的定位是什么 伊涅芙定位介绍 07-12
- 原神伊涅芙是哪个国家的 伊涅芙所属国家介绍 07-12
- 无畏契约源能行动官网地址 官网预约地址介绍 07-12
- ps怎样把相机拍摄的图片制作成手工写实插画的效果? 07-12