Avatar of SirParadox
SirParadox
 asked on

mssql BULK read an osfile and output

I am attempting to use the OPENROWSET(Bulk,... method to read an image, to be used as a column on a SQL View.

CREATE TABLE dbo.tblMyFiles
      (
      ID int NOT NULL IDENTITY (1, 1),
      FilePath varchar(255) NOT NULL
      )  ON [PRIMARY]
GO
INSERT INTO tblMyFiles (FilePath) VALUES ('c:\1\test.png')
GO


This works
 SELECT IMG=(SELECT CAST(bulkcolumn AS VARBINARY(MAX)) FROM OPENROWSET(BULK 'c:\1\test.png', SINGLE_BLOB ) AS x) FROM MyFiles WHERE ID=1

This does not work
 SELECT IMG=(SELECT CAST(bulkcolumn AS VARBINARY(MAX)) FROM OPENROWSET(BULK tblMyFiles.FilePath, SINGLE_BLOB ) AS x) FROM MyFiles WHERE ID=1

Server: Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'tblMyFiles'.


I've tried many different solutions.
 Quoting the tblMyFiles.FilePath...
 Putting it in an @Variable.

http://www.mssqltips.com/sqlservertip/1643/using-openrowset-to-read-large-files-into-sql-server/
http://www.sqlservercentral.com/Forums/Topic469199-5-1.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=143948

Any suggestions?
Microsoft SQL Server 2005SQL

Avatar of undefined
Last Comment
Vitor Montalvão

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
dsacker

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Vitor Montalvão

SirParadox, do you still need help with this question?
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck