declare @tname varchar(64) declare @tId int declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u' open cur_tb fetch next from cur_tb into @tname while @@fetch_status=0 begin exec('delete from voiceserver.dl.dbo.'+@tname+' aa inner join '+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0')----到这句时出错。 fetch next from cur_tb into @tname end close cur_tb deallocate cur_tb GO
try: declare @tname varchar(64) declare @tId int declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u' open cur_tb fetch next from cur_tb into @tname while @@fetch_status=0 begin exec('delete from 库名1..'+@tname+' aa inner join 库名2..'+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0') fetch next from cur_tb into @tname end close cur_tb deallocate cur_tb GO
declare @sql varchar(8000) set @sql = 'delete from 库名1..'+@tname+' aa inner join 库名2..'+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0' exec(@sql)试试!
declare @tname varchar(64) declare @tId int declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u' open cur_tb fetch next from cur_tb into @tname while @@fetch_status=0 begin exec('delete aa from opendatasource('SQLOLEDB', 'Data Source=服务器名;User ID=用户名;Password=密码').dl.dbo.'+@tname+' aa inner join '+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0')fetch next from cur_tb into @tname end close cur_tb deallocate cur_tb GO
declare @tId int
declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u'
open cur_tb
fetch next from cur_tb into @tname
while @@fetch_status=0
begin
exec('delete from voiceserver.dl.dbo.'+@tname+' aa inner join '+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0')----到这句时出错。
fetch next from cur_tb into @tname
end
close cur_tb
deallocate cur_tb
GO
declare @tname varchar(64)
declare @tId int
declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u'
open cur_tb
fetch next from cur_tb into @tname
while @@fetch_status=0
begin
exec('delete from 库名1..'+@tname+' aa inner join 库名2..'+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0')
fetch next from cur_tb into @tname
end
close cur_tb
deallocate cur_tb
GO
set @sql = 'delete from 库名1..'+@tname+' aa inner join 库名2..'+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0'
exec(@sql)试试!
declare @tId int
declare cur_tb cursor for select ltrim(rtrim(name)) name from sysobjects where xtype='u'
open cur_tb
fetch next from cur_tb into @tname
while @@fetch_status=0
begin
exec('delete aa from opendatasource('SQLOLEDB',
'Data Source=服务器名;User ID=用户名;Password=密码').dl.dbo.'+@tname+' aa inner join '+@tname+' bb on aa.ID=bb.ID and aa.Acroom_ID=bb.Acroom_ID where bb.UpLoad_Is=0')fetch next from cur_tb into @tname
end
close cur_tb
deallocate cur_tb
GO