开发者

How to append data from one table in another where one column is xml with sql?

Actually both tables are the same, and I just need to merge data. Problem is that one column is defined with XML shema, which is same in both tables, and for my query I am g开发者_C百科etting this error from sql server studio:

"Implicit conversion between XML types constrained by different XML schema collections is not allowed. Use the CONVERT function to run this query."

Help me writedown this query. I have something like this:

INSERT INTO table1
SELECT * FROM table2
WHERE id NOT IN (select id from table1);


Without more info on your table structure and the xml schemas I'm not sure how much assistance I can be. That said there's an article that discusses this exact problem here http://sqlblogcasts.com/blogs/martinbell/archive/2010/11/08/Using-XML-Schemas.aspx

And his example of using the convert statement to overcome exactly this problem is as follows.

INSERT INTO [dbo].[Test_ProductModel_Content](  [CatalogDescription] )
SELECT CONVERT(XML, [CatalogDescription] )
FROM AdventureWorks2008.Production.ProductModel
WHERE [CatalogDescription] IS NOT NULL ;
GO

Hope that helps, if not post more information and I'm sure someone can help you out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜