{"id":198,"date":"2012-05-11T12:39:35","date_gmt":"2012-05-11T12:39:35","guid":{"rendered":"https:\/\/sqlserverlearner.azurewebsites.net\/2012\/05\/11\/msg-206-level-16-state-2-line-6-operand-type-clash-int-is-incompatible-with-xml\/"},"modified":"2012-05-11T12:39:35","modified_gmt":"2012-05-11T12:39:35","slug":"msg-206-level-16-state-2-line-6-operand-type-clash-int-is-incompatible-with-xml","status":"publish","type":"post","link":"https:\/\/sqlserverlearner.com\/2012\/05\/11\/msg-206-level-16-state-2-line-6-operand-type-clash-int-is-incompatible-with-xml\/","title":{"rendered":"Msg 206, Level 16, State 2, Line 6 Operand type clash: int is incompatible with xml"},"content":{"rendered":"

Error:<\/strong>
\n
\nMsg 206, Level 16, State 2, Line 6
\nOperand type clash: int is incompatible with xml
\n<\/font><\/p>\n

This error comes up when you try to set XML variable with an int value.<\/p>\n

Sample Code:
\n[sql]
\nDECLARE @Var1 XML
\nDECLARE @Var2 INT<\/p>\n

SET @Var2 = 1<\/p>\n

SELECT @Var1 = @Var2
\n[\/sql]<\/p>\n

When you execute the above code you get this error at line 6
\nSELECT @Var1 = @Var2<\/strong><\/p>\n

Fix:
\nCheck all the XML related variables, columns in the table, Arguments to stored procedure, function etc…
\nand validate if the correct XML value is set.<\/p>\n

Applicable to SQL Server 2000,SQL Server 2005,SQL Server 2008,SQL Server 2008 r2,SQL Server 2012, SSIS<\/p>\n","protected":false},"excerpt":{"rendered":"

Error: Msg 206, Level 16, State 2, Line 6 Operand type clash: int is incompatible with xml This error comes up when you try to set XML variable with an int value. Sample Code: [sql] DECLARE @Var1 XML DECLARE @Var2 INT SET @Var2 = 1 SELECT @Var1 = @Var2 [\/sql] When you execute the above…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[128,1929],"tags":[1930],"_links":{"self":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/198"}],"collection":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":0,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"wp:attachment":[{"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sqlserverlearner.com\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}