国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 米泉市| 阿巴嘎旗| 长丰县| 石家庄市| 嘉禾县| 芦溪县| 嫩江县| 抚州市| 启东市| 武汉市| 虎林市| 曲沃县| 鹰潭市| 安宁市| 沅陵县| 乌拉特前旗| 民权县| 马尔康县| 瑞安市| 利津县| 龙口市| 耒阳市| 海阳市| 绿春县| 郑州市| 巍山| 边坝县| 汪清县| 东莞市| 讷河市| 启东市| 嫩江县| 柯坪县| 达孜县| 罗山县| 武强县| 芦溪县| 荔浦县| 南丹县| 房山区| 阳信县|