国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > 綜合 > 正文

批量修改Ms SqlServer 的default(默認值)

2024-07-21 02:44:47
字體:
來源:轉載
供稿:網(wǎng)友

1、取得數(shù)據(jù)庫所有表的默認值:

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 ;


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 天等县| 南通市| 龙里县| 揭西县| 吴堡县| 嘉祥县| 惠东县| 开化县| 门源| 兖州市| 彭水| 东光县| 朝阳市| 丽水市| 同江市| 镇江市| 丹巴县| 河源市| 湾仔区| 庆城县| 开封县| 通海县| 林口县| 武义县| 马公市| 卢湾区| 祁阳县| 射洪县| 石阡县| 彭阳县| 深水埗区| 梁河县| 泸西县| 宜昌市| 滁州市| 千阳县| 谢通门县| 大同县| 武冈市| 察哈| 噶尔县|