Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Import Image to a table

Author  Topic 

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-17 : 05:37:38
Hi,

The syntax below gives me an error;

Msg 102, Level 15, State 1, Line 3
Incorrect syntax near 'Bulkcolumn'.


Insert into dbo.tblUser(Signature)

Select * Bulkcolumn from OPENROWSET(BULK N'R:\ODSTbls\Gerry sig2.JPG', SINGLE_BLOB) as Signature
where user_name = McCannG


I am trying to import an image (signature) to a fieldname called Signature where user_name = McCannG.
Siganture has the data type Image

Any help please. Thanks

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-17 : 07:09:19
Changed the code to:

Insert into dbo.tblUser(Signature)

Select * from OPENROWSET(BULK N'R:\ODSTbls\Gerry.JPG', SINGLE_BLOB) as Signature
where user_name = McCannG



Received the error-

Msg 4861, Level 16, State 1, Line 1
Cannot bulk load because the file "R:\ODSTbls\Gerry.JPG" could not be opened. Operating system error code 3(error not found).
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2010-06-17 : 07:21:24
Can the server see the R Drive? or is this a dirve letter visible from your own PC?
Does the server have access to this share/directory/file?
Go to Top of Page

dr223
Constraint Violating Yak Guru

444 Posts

Posted - 2010-06-17 : 07:51:27
ok, managed to bring it but when I have the following code

Insert into dbo.TblUser(Signature)
Select * from OPENROWSET(BULK N'C:\Signatures\Gerry.JPG', SINGLE_BLOB) as signature
where user_name = 'McCannG'

I receive the error;

Msg 207, Level 16, State 1, Line 3
Invalid column name 'user_name'.

and there is a column name = user_name, when I delete the where clause it creates a new balnk record and signature is popualated accordingly.

But I want to update an existing record


thanks
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2010-06-18 : 04:13:30
a) off the wall suggestion - case sensitive database - is the column name matching it's definition?
b) how does the JPEG have a column named user_name in it?
the WHERE clause applies to your SELECT not the INSERT
Go to Top of Page
   

- Advertisement -