Opening local XML file - XML SOAP
This is a discussion on Opening local XML file - XML SOAP ; Good evening
I want to open a local XML file from my SQL script.
#1. If you are in some dev't environment such as .Net or script, you can
open the file and pass it into the SQL script. But ...
-
Opening local XML file
Good evening
I want to open a local XML file from my SQL script.
#1. If you are in some dev't environment such as .Net or script, you can
open the file and pass it into the SQL script. But I want that within SQL
script.
#2. You can write a CLR function to open it. I did. However I feel like pay
too much for such a trivial job.
#3. I found a way to retrieve a file as base64 string. e.g.,
declare @b varbinary(max)
set @b=(select * from openrowset(bulk N'c:\x.xml', single_blob) as b)
That looks like decent base64 binary text which can be converted into XML
stream easily, if you are in .Net. But how do you do that within SQL script?
Or is there another way #4, #5, ... I have not imagined?
#2 UDF
public static SqlXml getdoc(string xmlPath)
{
XmlReader xr = XmlReader.Create(xmlPath);
SqlXml retSqlXml = new SqlXml(xr);
xr.Close();
return (retSqlXml);
}
--
Pohwan Han. Seoul. Have a nice day.
-
Re: Opening local XML file
declare @b xml
set @b=(select * from openrowset(bulk N'c:\x.xml', single_blob) as b)
SELECT @b
VARBINARY can be implicitly converted to xml, assuming the stream actually
is xml.
Dan
> declare @b varbinary(max)
> set @b=(select * from openrowset(bulk N'c:\x.xml', single_blob) as b
-
Re: Opening local XML file
Thanks Dan.
It worked.
--
Pohwan Han. Seoul. Have a nice day.
"Dan Sullivan" <danATpluralsight.com> wrote in message
news:964a9ae6140488c868bbaa3f4180@news.microsoft.com...
> declare @b xml
> set @b=(select * from openrowset(bulk N'c:\x.xml', single_blob) as b)
> SELECT @b
>
> VARBINARY can be implicitly converted to xml, assuming the stream actually
> is xml.
>
> Dan
>
>> declare @b varbinary(max)
>> set @b=(select * from openrowset(bulk N'c:\x.xml', single_blob) as b)
>
>
Similar Threads
-
By Application Development in forum Inetserver
Replies: 1
Last Post: 08-29-2007, 06:18 PM
-
By Application Development in forum Graphics
Replies: 9
Last Post: 02-24-2007, 02:15 PM
-
By Application Development in forum Adobe Acrobat
Replies: 0
Last Post: 01-26-2006, 09:56 AM
-
By Application Development in forum Perl
Replies: 2
Last Post: 10-14-2005, 02:02 PM
-
By Application Development in forum Javascript
Replies: 4
Last Post: 07-02-2004, 10:57 PM