【问题标题】:sql server linked oracle how to execute query with datasetsql server链接oracle如何使用数据集执行查询
【发布时间】:2019-03-18 08:02:01
【问题描述】:

在 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 中一次访问整个表,请求会挂起, 大量数据

【问题讨论】:

    标签: sql-server oracle openquery


    【解决方案1】:

    找到解决办法

     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+')')
    

    【讨论】:

    • 任何解决方案:在oracle中使用xmltable函数,在sql server中使用xml
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-02-02
    • 2014-04-07
    • 2019-03-29
    • 1970-01-01
    • 1970-01-01
    • 2020-04-05
    • 1970-01-01
    相关资源
    最近更新 更多