zoukankan      html  css  js  c++  java
  • SQL Server error "Xml data type is not supported in distributed queries" and workaround for it

    Recently while working with data migration,got an error while running a following query where Server2 has beed added as linked server.

    SELECT 
    * 
    FROM Server1.Database1.dbo.Table1 
    WHERE Column1 NOT IN
    (SELECT Column1 FROM Server2.Database2.dbo.Table1)
    GO
    
    -- Error raised while run above query
    "Xml data type is not supported in distributed queries. Remote object 'Server2.Database2.dbo.Table1' has xml column(s)."

    Server2.Database2.dbo.Table1 objects has another column named 'column2' has xml datatype and we have not used it anywhere in query. We used 'column1' of that table only and it has not xml datatype, even it has raised error. For the solution to avoid such error i have revised query as following.
    SELECT 
    * 
    FROM Server1.Database1.dbo.Table1 
    WHERE Column1 NOT IN
        (
        SELECT
        	  *
        FROM
        OPENQUERY(Server2,'
        			SELECT 
        			Column1
        			FROM Database2.dbo.Table1'
        		) linked
        )


    这是网上查到的资料
    根据这个,我先把xml转化成nvarchar, 在转回去变成xml

    SELECT top 100 [Internal Database ID],[Internal Database Search ID],[Watch List Code],[Watch List Description], CONVERT(xml, CAST([Watch List Record Detail] as nvarchar(max))) [Watch List Record Detail] FROM OPENQUERY( [172.16.4.169] ,
    'SELECT top 100 [Internal Database ID], [Internal Database Search ID],[Watch List Code],[Watch List Description], CAST([Watch List Record Detail] as nvarchar(max)) [Watch List Record Detail] FROM [VeridocsECCM].[dbo].[VML_View_WatchListHits]')

  • 相关阅读:
    数组排序 -- 冒泡排序
    数组自带的函数(方法)
    京东官网轮播图的实现
    鼠标单击元素输出对应元素的索引号
    JavaScript中获取HTML元素的方式
    JavaScript数组的2种定义方式
    this关键字
    JavaScript中对象的3种定义方式
    Hadoop完整搭建过程(三):完全分布模式(虚拟机)
    Hadoop完整搭建过程(二):伪分布模式
  • 原文地址:https://www.cnblogs.com/facial/p/4581084.html
Copyright © 2011-2022 走看看