SQL Server : Insert Image Into Table Dynamically -


I have a SQL server table product and I insert an image for each in the image The column based on the product Code where the name of the image is similar to the product code .

  Update Products Product ProdImage = (SELECT * from OpenRoseet (Bulk 'C: \ USER \ DLL \ Desktop \ ImageCabank \ sbrk.jpg', single_blob) as the image where the code = 'Sbrk' GO  

is the name of the image and code sbrk I get an exception when I tried to make the path dynamic :

Expect STRING, TEXT_LEX

me Looks like you can use dynamic SQL to make dynamic dynamic Will need. You can not go to a parameter only in the bulk statement:

  announcement @ sql NVARCHAR (max) DECLARE @ PATH N VARCHAR (MAX) DECLARE @ CODE NVARCHAR (200) SET @ path = ' C: \ user \ del \ Desktop \ ImageCatalog \ sbrk.jpg 'SET @ code =' sbrk 'SET @sql =' Update Product Set Prodame = (SELECT * FROM Openerate (Bulk N '+ + Path +' '' , Single_blob as image) where code = '' '+ + code +' '' 'EXEC SP_executesql @ sql  

UPDATE

< P> This is correct in the turbochuck (no representative to report). I have missed part about the image file name:

  DECLARE @sql NVARCHAR DECLARE @ path NVARCHAR (maximum) DECLARE @ CODE NVARCHAR (200) SET @ path = 'C : \ User \ del \ Desktop \ ImageCatalog \ 'SET @code =' sbrk 'SET @sql =' Update Product Set Prodame = (SELECT * FROM Openrowset (Bulk N '' + + + + + + + + + Code + ' Jpg '', single_Blob) image WHERE CODE = '' '+ code =' '' 'EXEC sp_executesql @ sql  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -