1、使用游标
declare @sql varchar(200), @name varchar(40) declare my_cursor scroll cursor for select name from sysobjects where type = 'u' and name like 'jobs_%' open my_cursor fetch next from my_cursor into @name while(@@fetch_status=0) begin print 'processing ' + @name set @sql = N'alter table testbfcmisuser.' + @name + N' add note varchar(200)' exec(@sql) print 'finished' fetch next from my_cursor into @name end close my_cursor deallocate my_cursor
2、使用临时表
declare @sql varchar(200), @name varchar(100), @count int select identity(int, 1, 1) as ID, name into #JobTable from sysobjects where type = 'u' and name like 'Jobs_%' set @count=@@rowcount while @count>0 begin select top 1 @name = name from #JobTable where id = @count print 'processing ' + @name set @sql = N'alter table testbfcmisuser.' + @name + N' add note varchar(200)' exec(@sql) print 'finished' set @count = @count - 1 end drop table #JobTable
下载说明
☉本站所有源码和资源均由站长亲自测试-绝对保证都可以架设,运营!
☉如源码和资源有损坏或所有链接均不能下载,请告知管理员,
☉本站软件和源码大部分为站长独资,资源购买和收集,放心下载!
☉唯一站长QQ:1004003180 [人格担保-本站注重诚信!]
☉购买建议E-mail:1004003180@qq.com 源码收购 E-mail:1004003180@qq.com
☉本站文件解压密码 【文章内都自带解压密码,每个密码不同!】