Solved

INSERT IMAGES IN MSSQL TABLE

Posted on 2014-01-05
1
415 Views
Last Modified: 2014-01-06
Dear Experts,

I have a code that looks like this:

UPDATE Categories
SET CategoryPicture =
      (SELECT * FROM OPENROWSET(BULK N'C:\Temp\Beverages.jpg', SINGLE_BLOB) AS CategoryImage)
WHERE CategoryID = 1

From my stored procedure, i want to replace 'C:\Temp\Beverages.jpg' with a variable name @x1 so that i can pass @x1 as a paramater each time CategoryID changes.

Please help with necessary codes or alternatives.

Thank you.
0
Comment
Question by:ukconcepts
1 Comment
 
LVL 11

Accepted Solution

by:
Louis01 earned 500 total points
ID: 39758646
DECLARE @SQL varchar(max);
DECLARE @x1 varchar(max) = 'C:\Temp\Beverages.jpg';

SET @SQL = 'UPDATE Categories 
                            SET CategoryPicture = (SELECT BulkColumn FROM OPENROWSET(BULK N''' + @x1 + ''', SINGLE_BLOB) CategoryImage) 
WHERE CategoryID = 1';

EXECUTE (@SQL);

Open in new window

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now