简体   繁体   English

SQL Server 2008 R2:导出XML BLOB并作为表导入回到SQL

[英]SQL Server 2008 R2: Export XML BLOB and import back into SQL as table

I have a client application that generate a database into my SQL Server. 我有一个客户端应用程序,可以在我的SQL Server中生成数据库。 The generated database contains a BLOB data (image data type) of an XML file. 生成的数据库包含XML文件的BLOB数据(图像数据类型)。 My question is how best would I be able to use and read the data inside the XML file (for generating a web report). 我的问题是,如何才能最好地使用和读取XML文件中的数据(用于生成Web报告)。 Would it be possible to a good idea to export the BLOB data into an XML file on the disk and import the XML back into SQL as table database. 最好将BLOB数据导出到磁盘上的XML文件中,然后将XML作为表数据库导入到SQL中。 If yes, how would I go about doing this? 如果是,我将如何去做? Would I be using BCP to export the BLOB out into XML file? 我将使用BCP将BLOB导出到XML文件中吗? Also is it possible to import the XML back without predetermining / pre-creating the columns in the table? 还可以在不预先确定/未创建表中的列的情况下将XML导入回来吗? Thanks!! 谢谢!!

Unless, there is a need to do indexing / filtering / other analysis on various columns, there is no need to split the xml into various columns. 除非需要对各个列进行索引/过滤/其他分析,否则就无需将xml拆分为各个列。

SQL Server 2008 R2 has xml support and a single table with two column ID and XMLData should work for straight forward storage and retrieval, for example: SQL Server 2008 R2具有xml支持,并且具有两个列ID的单个表和XMLData应该可以直接存储和检索,例如:

CREATE TABLE T1(Col1 int primary key, Col2 xml) 

INSERT INTO T values(1,'<ProductDescription ProductID="1">iPhone</ProductDescription>')

Refer to the msdn article " Implementing XML in SQL Server " for syntax and other help. 有关语法和其他帮助,请参阅msdn文章“ 在SQL Server中实现XML ”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM