Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Hi All,I am trying to extract xml data from xml file into MS SQL DB.For this I use following code in SP.SET @XDoc = ( SELECT * FROM OPENROWSET (BULK @VCnfVal, SINGLE_CLOB ) AS xmlData)Please note that I want @VCnfVal as one variable and not hard-coded. Below code works fine but code 1 fails. Please let me know how to use the xml variable path instead of one fixed value of the xml path.SET @XDoc = ( SELECT * FROM OPENROWSET (BULK 'C:\Documents and Settings\sheetal\Desktop', SINGLE_CLOB ) AS xmlData)
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts
Posted - 2007-10-15 : 10:11:23
I believe you will have to use D-sql in this case.
declare @doc XMLdeclare @sql nvarchar(max)set @sql = N'select @doc = convert(xml,mycol) from openrowset(bulk ''' + @@VCnfVal + N''', SINGLE_BLOB) as Temp(mycol)'exec sp_executesql @sql , N'@doc XML OUTPUT', @doc OUTPUTSelect @doc
Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"