Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Comparing two columns with different data types

$
0
0

Hi

I am trying to compare two columns in different databases (using linked server connection). Both columns are phone numbers but one of the columns is xml data. When I run the following query:

SELECT
      Cast(a.XML_Data as XML) as XML_Data, b.phone
FROM
      OPENQUERY(NJRAPDB01,'
          SELECT
           Cast(dlr_reference_num as Varchar(max)) as XML_DATA
         FROM
           marlin.dbo.dealer') a, marlin_x.dbo.vendor b
Where  Cast(a.XML_Data as XML) = b.phone          

I get this error:The data types xml and char are incompatible in the equal to operator

Any suggestion would be appreciated.

Doug 


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>