点滴积累【other】---存储过程修改表的所有字段(sql)

 1 USE [QG_Mis24]
 2 GO
 3 /****** Object:  StoredProcedure [dbo].[p_set]    Script Date: 07/11/2013 17:05:38 ******/
 4 SET ANSI_NULLS ON
 5 GO
 6 SET QUOTED_IDENTIFIER ON
 7 GO
 8  ALTER procedure [dbo].[p_set]   
 9  as   
10  declare tb cursor for  
11  SELECT sql='alter table ['+d.name   +'] alter column bgdlx Varchar(64) '  
12  FROM syscolumns a left join systypes b on a.xtype=b.xusertype  
13  inner join sysobjects d on a.id=d.id and a.name like '%bgdlx%' and a.length =10    
14  order by d.name,a.name   declare @sql varchar(1000)   
15  open tb   fetch next from tb into @sql   while @@fetch_status = 0   
16  begin   print @sql  
17  exec(@SQL)  fetch next from tb into @sql   
18  end   
19  close tb   
20  deallocate tb  
原文地址:https://www.cnblogs.com/xinchun/p/3185479.html