Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Inserting from an XML file (Incompatible types)

Author  Topic 

kfluffie
Posting Yak Master

103 Posts

Posted - 2011-12-08 : 16:47:47
Hi,
I am trying to insert data to a table from an XML file however i get an error in SSMS:

DECLARE @xmlDoc XML
SET @xmlDoc =(
SELECT * FROM OPENROWSET (
BULK 'D:\Studier\MCTS\ML326C - XML i Relationsdatabaser\Projektfiler\faktura_1.xml', SINGLE_BLOB
) AS xmlData
)

SELECT @xmlDoc -- FROM


SELECT
@xmlDoc.query('/FAKTURA/FÖRETAG/ORGNR'),
@xmlDoc.query('/FAKTURA/KÖPARE/FÖRETAGSNAMN')
(SELECT anst_id FROM HR.Anställd
WHERE @xmlDoc.query('/FAKTURA/KÖPARE/BESTÄLLARE') = fornamn)


The error message is:
Msg 402, Level 16, State 1, Line 18
The data types xml and varchar are incompatible in the equal to operator.


I first thought it was because it was a char(20) column but this gives the same error:
	SELECT 
@xmlDoc.query('/FAKTURA/FÖRETAG/ORGNR'),
@xmlDoc.query('/FAKTURA/KÖPARE/FÖRETAGSNAMN')
(SELECT anst_id FROM HR.Anställd
WHERE @xmlDoc.query('/FAKTURA/KÖPARE/BESTÄLLARE') = 'word')


Can anyone assist me with this?

Best regards,
KFluffie

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-09 : 01:26:28
how will be structure of xml in field? will it have only single node for /FAKTURA/KÖPARE/BESTÄLLARE?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -