October 21, 2008 at 7:16 am
Guys,
I have create table with ID and column testimage
CREATE TABLE IMAGE_TEST
(
ID INT IDENTITY (1, 1) NOT NULL,
TEST_IMAGE IMAGE
)
How do I insert an image in this table with DML sql statements is it possible? or does it have to be done using application code
Thanks
October 21, 2008 at 7:26 am
INSERT INTO Table (ImageColumn)
SELECT * FROM OPENROWSET (BULK N'C:\YourPicture.bmp', SINGLE_BLOB)
October 21, 2008 at 8:41 am
when I run the insert statement I get the following error.
Msg 491, Level 16, State 1, Line 1
A correlation name must be specified for the bulk rowset in the from clause.
October 22, 2008 at 8:15 am
The sample provided was a syntax example. It would not work against your table. Refer to the Books Online (BOL) and adjust to your table name, column name, etc.
There is a minor correction to the syntax: the OPENROWSET query has to have an alias and be coded as a subquery such as:
(SELECT * FROM OPENROWSET(BULK N'file name', SINGLE_BLOB) AS x)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply