Importing Images in SQL Server: Follow On -
this follow on question dynamic sql solution found on stack overflow. use code model used in previous example. problem getting following error: msg 4104, level 16, state 1, line 1 multi-part identifier "abc123.jpg" not bound , not understand why image names indeed loaded. @ wits end. feel close making solution work cannot beyond issue.
please find sample code below:
declare assetcursor cursor fast_forward select image_file_name images declare @sql nvarchar(4000) declare @image_file_name varchar(50) open assetcursor while (1=1) begin fetch next assetcursor @image_file_name if @@fetch_status<>0 break set @sql = n'update dbo.images set doc_image = (select * openrowset(bulk n''c:\myimages\' + cast(@image_file_name varchar(50)) + n'.jpg'', single_blob) img) image_file_name = ' + cast(@image_file_name varchar(50)) exec(@sql) end /* while */ close assetcursor deallocate assetcursor
try
where image_file_name = '' + cast(@image_file_name varchar(50)) + ''
where '' 2 single-quotes, not double quote. you're building dynamic sql literal string within needs layer of apostrophies
Comments
Post a Comment