Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bring An XML File Into SQL 2005 1

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
0
0
US
I have a big XML file I want to pull into SQL 2005.
I have a feeling I am missing somtheing obvious here but here goes...

In T-SQL how can I define the XML file and import it into a
declared variable that I can then shred using OPENXML or .NODES. Is the usual method to simply suck it in via DTS into a table field and then load it into a locally declared variable in a T-SQL process?

Come to think of it I guess spitting out data again afterwards to an XML file would be the same thing in reverse?


Dazed and confused
N+, MCDBA 2000, MCAD .NET
 
Fastest way would be OPENROWSET(BULK

Code:
create table SomeTable (id int identity not null,
Doc XML not null);
GO

insert into SomeTable(Doc)
select * from OPENROWSET(BULK 'C:\SomeTable.xml',SINGLE_BLOB) as x

declare @doc varchar(max)
select @doc = convert(varchar(max),doc) from SomeTable

select @doc

Denis The SQL Menace
SQL blog:
Personal Blog:
 
Ok thanks chap - I shall have a fiddle with your example.

Dazed and confused
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top