declare @tablename varchar(50),@sql varchar(3000) declare table1 cursor for select object_name(a.id)as tablename from syscolumns a, sysobjects b, systypes c where a.id=b.id and a.xtype=c.xtype and b.xtype='u' and c.name in('varchar','nvarchar','char','nchar','text','ntext')and object_name(a.id)<>'t' and a.name='gsbh' order by object_name(a.id) open table1 fetch next from table1 into @tablename while @@FETCH_STATUS = 0 begin select @sql='update '+@tablename+' set gsbh=''117'' where gsbh=''118''' exec(@sql) fetch next from table1 into @tablename end close table1 deallocate table1 |
|
來自: 自信開朗 > 《sqlserver過程》