I need to export some images into my SQL Server through HTTP URL.
I've found article about exporting of XML data:
sp_configure 'show advanced options', 1;
GO
RECONFIGURE;
GO
sp_configure 'Ole Automation Procedures', 1;
GO
RECONFIGURE;
GO
Declare @Object as Int;
Declare @ResponseText as Varchar(8000);
Declare @Url as Varchar(MAX);
select @Url = 'http://somexml.com/xmlfile.xml'
Exec sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
Exec sp_OAMethod @Object, 'open', NULL, 'get', @Url, 'false'
Exec sp_OAMethod @Object, 'send'
Exec sp_OAMethod @Object, 'responseText', @ResponseText OUTPUT
Exec sp_OADestroy @Object
--load into Xml
Declare @XmlResponse as xml;
select @ResponseText
Also during research I've found that I should use ADODB.Stream for binary data. But I can't figure out how to read this object using approach described above. Is there a way for reading binary data in pure TSQL or I should use CLR for this?
Thanks a lot for helping.