Sunday, February 12, 2012

Can't import image when size is more then 8K using "microsoft.xmlhttp"

I'm using following script to import image into SQL Server from web and it does not work for image 2 (http://dbalinks.com/images/mol2.jpg) but it work for image 1 (http://dbalinks.com/images/mol1.jpg):

declare @.local int
declare @.retcode int
declare @.status int
declare @.url varchar(2000)

create table #httpresult(pic image)

--set @.url = 'http://dbalinks.com/images/mol1.jpg'
set @.url = 'http://dbalinks.com/images/mol2.jpg'

exec @.retcode = sp_oacreate 'microsoft.xmlhttp', @.local out
exec @.retcode = sp_oamethod @.local, 'open', null, 'get',@.url , 'false'
exec @.retcode = sp_oamethod @.local, 'send', null, @.status
exec @.retcode = sp_oagetproperty @.local, 'status', @.status out
insert #httpresult (pic)
exec @.retcode = sp_oagetproperty @.local, 'responsebody'

select * from #httpresult

drop table #httpresult

exec sp_oadestroy @.local


Is it possible to import image larger then 8K into SQL Server from the web using T-SQL and stored procedure?

Is there any chance that admin can do something about this?

Maybe using stream:

exec sp_oacreate 'adodb.stream',@.o OUT
exec sp_oasetproperty @.o,'Type',adTypeBinary

or something like that.

No comments:

Post a Comment