﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Programming / XML  / OPENXML error converting nvarchar to numeric. / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sun, 19 May 2013 23:35:52 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: OPENXML error converting nvarchar to numeric.</title><link>http://www.sqlservercentral.com/Forums/Topic13069-21-1.aspx</link><description>Hello all,Please see the filter I have provided on the SFARBE column in the WITH block. This avoids including blank strings.[code="plain"]SELECT SFARBE,RREFERENZ FROM OPENXML (@idoc, 'FARBE' ,1) WITH ( SFARBE NUMERIC(21,0) '/FARBE/FARBE.INFR/SFARBE[.!=""]',RREFERENZ CHAR(20) '/FARBE/FARBE.INFR/RREFERENZ' )[/code]</description><pubDate>Mon, 04 Mar 2013 14:47:44 GMT</pubDate><dc:creator>Graham O'Daniel</dc:creator></item><item><title>RE: OPENXML error converting nvarchar to numeric.</title><link>http://www.sqlservercentral.com/Forums/Topic13069-21-1.aspx</link><description>Thanks for the info.That sounds like a greate idea.I have used the edgetable as a workaround and then just cast the value which now also works. </description><pubDate>Thu, 12 Jun 2003 02:10:00 GMT</pubDate><dc:creator>neilswart</dc:creator></item><item><title>RE: OPENXML error converting nvarchar to numeric.</title><link>http://www.sqlservercentral.com/Forums/Topic13069-21-1.aspx</link><description>Empty or null elements within an xml fragment fail to convert when numeric or decimal format is used, eventhough  such conversion goes without a problem In a normal select statment. However, I noticed that float works just fine. Why? I don't know.  I used the following approach to this problem:a) if precision and scale components of the number ( e.g. Decimal(19,10) ) are important  then I make sure default of 0 is used in the xml fragment instead of empty or null. b)If percision and scale arenot important then I use float in the select statemnt. In your case you used Numeric(20,0) to report just the integer part. Float will work fine.Hope this helps. </description><pubDate>Wed, 11 Jun 2003 15:01:00 GMT</pubDate><dc:creator>oabusa</dc:creator></item><item><title>OPENXML error converting nvarchar to numeric.</title><link>http://www.sqlservercentral.com/Forums/Topic13069-21-1.aspx</link><description>Please take a look a the following.I do a select for OPENXML but it returns withServer: Msg 8114, Level 16, State 5, Line 24Error converting data type nvarchar to numeric.because the value for sfarbe is empty or null.DECLARE @idoc INTDECLARE @doc  VARCHAR(3000)SET @doc ='&amp;lt;?xml version="1.0"?&amp;gt;&amp;lt;FARBE&amp;gt; &amp;lt;FARBE.INFR&amp;gt;  &amp;lt;SFARBE&amp;gt;&amp;lt;/SFARBE&amp;gt;  &amp;lt;SFIRMA&amp;gt;&amp;lt;/SFIRMA&amp;gt;  &amp;lt;SGUELTIGVON&amp;gt;&amp;lt;/SGUELTIGVON&amp;gt;  &amp;lt;DGUELTIGBIS&amp;gt;&amp;lt;/DGUELTIGBIS&amp;gt;  &amp;lt;RREFERENZ&amp;gt;\*blue\*&amp;lt;/RREFERENZ&amp;gt;  &amp;lt;XUFNUMMER&amp;gt;&amp;lt;/XUFNUMMER&amp;gt;  &amp;lt;XRALNUMMER&amp;gt;&amp;lt;/XRALNUMMER&amp;gt;  &amp;lt;XSPRACHE&amp;gt;&amp;lt;/XSPRACHE&amp;gt;  &amp;lt;XTEXT&amp;gt;&amp;lt;/XTEXT&amp;gt;  &amp;lt;XKURZTEXT&amp;gt;&amp;lt;/XKURZTEXT&amp;gt;  &amp;lt;XLANGTEXT&amp;gt;&amp;lt;/XLANGTEXT&amp;gt;  &amp;lt;XABKUERZUNG&amp;gt;&amp;lt;/XABKUERZUNG&amp;gt; &amp;lt;/FARBE.INFR&amp;gt;&amp;lt;/FARBE&amp;gt;'EXEC sp_xml_preparedocument @idoc OUTPUT, @docSELECT SFARBE,RREFERENZ FROM OPENXML (@idoc, 'FARBE' ,1)  WITH (  SFARBE    NUMERIC(21,0) '/FARBE/FARBE.INFR/SFARBE',        RREFERENZ CHAR(20)      '/FARBE/FARBE.INFR/RREFERENZ' )EXEC sp_xml_removedocument @idocIs there a workaround for this ?? </description><pubDate>Wed, 11 Jun 2003 04:57:00 GMT</pubDate><dc:creator>neilswart</dc:creator></item></channel></rss>