我需要通过 HTTP URL 将一些图像导出到我的 SQL Server。
我找到了关于导出 XML 数据的文章:
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
Run Code Online (Sandbox Code Playgroud)
同样在研究期间,我发现我应该对二进制数据使用ADODB.Stream。但我无法弄清楚如何使用上述方法读取此对象。有没有办法在纯 TSQL …