在sql server中,我有一个带有id的表。我在一个循环中通过openquery传递id。
while @coun < 1000
begin
select @id=id from #temp where num = @coun
@sql = 'select * from tableoracle where id=' + @id
execute('insert into #temp2 select * from openquery(ORAC, ' + @sql+')')
set @coun = @coun + 1
End
我可以立即发送id作为一组而不是逐个发送吗?
如果您在没有id的情况下一次访问oracle中的整个表,则请求将挂起,并且会产生大量数据。
发布于 2018-10-28 16:25:59
找到解决方案
declare @a varchar(max) = (select '(' + stuff (
(SELECT ',''' +id + ''''
FROM #temp
for xml path('')),
1, 1, '') + ')')
@sql = 'select * from tableoracle where id in ' + @a
execute('insert into #temp2 select * from openquery(ORAC, ' + @sql+')')
https://stackoverflow.com/questions/52790532
复制相似问题