February 1, 2008 at 3:59 pm
Hello, I found this code on the net for uploading images into SQL Server tables using T-SQL. Looks pretty straight forward, but I seem to not be able to get it to work. Can anyone tell me if I'm missing something?
Here is the SQL:
INSERT INTO MyTable (BinaryField)
SELECT * FROM OPENROWSET(BULK N'C:\Image1.jpg', SINGLE_BLOB)
The error I'm getting is:
A correlation name must be specified for the bulk rowset in the from clause
I'm not sure what this means, so I'm not sure how to correct it.
Thanks,
Strick
February 1, 2008 at 4:35 pm
The path to the file is from the server point of view!
If you write "c:" it is ON THE SERVER, not your local machine "c:".
use unc paths...
N 56°04'39.16"
E 12°55'05.25"
February 1, 2008 at 6:09 pm
Google's your friend 🙂
Visit one of the first links in google's results (http://technet.microsoft.com/en-us/library/ms190312.aspx)
Then search on the page for correlation and you'll see how to make it work.
Long story short, you need to do this
INSERT INTO MyTable (BinaryField)
SELECT * FROM OPENROWSET(BULK N'C:\Image1.jpg', SINGLE_BLOB) MyBulkImage
where MyBulkImage can be anything 😀
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply