批量修改Ms SqlServer 的default(默认值)
2024-09-03 21:43:46
原文:批量修改Ms SqlServer 的default(默认值)
--1、取得数据库所有表的默认值:
select
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 ;
最新文章
- Xshell显示中文乱码问题
- C# 如何给sql数据库的日期字段插入空值
- php测试程序运行时间和占用内存情况
- 距离矢量路由协议举例——RIP
- iOS AvPlayer AvAudioPlayer音频的后台播放问题
- 路径问题以及cookie详解
- 分享几种Linux软件的安装方法
- asp.net mvc框架的一些切入点
- OpenCV成长之路:图像直方图
- ch4-注册 登陆 实现 cookie使用
- Redis~Linux环境下的部署
- python基础篇实战
- 主机配置nginx后如何获取访问者IP
- ABP框架系列之八:(Introduction-介绍)
- 【Mybatis】XML配置实现增删改查
- #pragma的一些用法
- 爱奇艺视频显示列表CSS实现
- loadrunner中controller 中scenario->; rendezvous灰色不可用的解决方法:
- web自动化测试:watir+minitest(四)
- 使用 Python 开始你的机器学习之旅【转】
热门文章
- 0x04 Python logger 支持多进程日志按大小分割
- linux系统盘扩容操作
- [转]【会话技术】Session技术
- 浅析 fstab 与移动硬盘挂载方法
- springboot 整合 freemarker
- 用JSON.parse(JSON.stringify(itemData))序列化反序列化实现‘深度复制’
- 爬虫-selenium的使用
- JDOJ 1133 分段公司利润
- 【java异常】Expected one result (or null) to be returned by selectOne(), but found: 63
- 洛谷 P1801 黑匣子_NOI导刊2010提高(06) 题解