您的位置:首页 > 数据库

SQL SERVER 批量修改字段的数据类型

2010-06-25 10:15 344 查看
create   procedure   p_set  
  as  
  declare   tb   cursor   for  
  SELECT   sql='alter   table   ['+d.name  
  +']   alter   column   ['+a.name+']   '  
  +b.name+'(8,3)'  
  FROM syscolumns a left   join   systypes   b   on   a.xtype=b.xusertype  
  inner   join   sysobjects   d   on   a.id=d.id     and   d.xtype='U'   and     d.name<>'dtproperties'  
  where    
  b.name   in('decimal')  
   order   by   d.name,a.name  
      declare   @sql   varchar(1000)  
  open   tb  
  fetch   next   from   tb   into   @sql  
  while   @@fetch_status   =   0  
  begin  
  print @sql
  exec(@SQL)
  fetch   next   from   tb   into   @sql  
  end  
  close   tb  
  deallocate   tb  
  go
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  sql server sql join table go