Load XML data from a file to table : XML « XML « SQL Server / T-SQL Tutorial






3> CREATE TABLE dbo.VisioDocs
4> (
5>   id  INT NOT NULL,
6>   doc XML NOT NULL
7> );
8> GO
1>
2> INSERT INTO dbo.VisioDocs (id, doc)
3>   SELECT 1, *
4>   FROM OPENROWSET(BULK 'C:\ORM.vdx',
5>     SINGLE_BLOB) AS x;
6>  INSERT INTO dbo.VisioDocs (id, doc)
7>   SELECT 2, *
8>   FROM OPENROWSET(BULK 'C:\ER.vdx',
9>     SINGLE_BLOB) AS x;
10>  INSERT INTO dbo.VisioDocs (id, doc)
11>   SELECT 3, *
12>   FROM OPENROWSET(BULK 'C:\UML.vdx',
13>     SINGLE_BLOB) AS x;
14>  INSERT INTO dbo.VisioDocs (id, doc)
15>   SELECT 4, *
16>   FROM OPENROWSET(BULK 'C:\ER.vdx',
17>     SINGLE_BLOB) AS x;
18> GO
Msg 4860, Level 16, State 1, Server J\SQLEXPRESS, Line 2
Cannot bulk load. The file "C:\ORM.vdx" does not exist.
1> SELECT doc.query('
2~   declare namespace VI="http://schemas.microsoft.com/visio/2003/core";
3~   for $v in /VI:VisioDocument/VI:DocumentProperties
4~   return element Person
5~     {
6~        attribute creatorname
7~                  {$v/VI:Creator[1]/text()[1]}
8~     }')
9> FROM dbo.VisioDocs;
10> GO
Msg 1934, Level 16, State 1, Server J\SQLEXPRESS, Line 1
SELECT failed because the following SET options have incorrect settings: 'QUOTED_IDENTIFIER'. Verify that SET options are correct for use with indexed views and/or indexes on computed columns and/or q
uery notifications and/or xml data type methods.
1>
2>
3> drop table VisioDocs;
4> GO








24.1.XML
24.1.1.XML type column
24.1.2.Insert XML data to database
24.1.3.Insert XML data to a XML type column
24.1.4.Creating xml Data Type Columns and insert data
24.1.5.Create index on XML column
24.1.6.Load XML data from a file to table
24.1.7.Modifying XML Data