vendredi 10 juin 2016

Inserting a XML table into a SQL table

I'm trying to put a XML file into a SQL table. I've successfully gotten the XML file into the SQL server using the following code:

declare @xmldata as xml

set @xmldata = (SELECT CONVERT(XML, BulkColumn)AS Bulkcolumn
FROM OPENROWSET (BULK 'filedestination', SINGLE_BLOB) as X)

and the following snippet of code is where I get an error. I'm aware that I must use an INSERT INTO statement but I'm not sure where I'm going wrong here.

INSERT INTO t1(c1, c2, c3)
SELECT  
c1 AS 'c1',
c2 AS 'c2',
c3 as 'c3'

I'm currently using SQL Server 2005.

Aucun commentaire:

Enregistrer un commentaire