?
Solved

Using OPENROWSET twice in one SQL statement

Posted on 2014-03-05
1
Medium Priority
?
379 Views
Last Modified: 2014-03-07
I have two filestream columns in a table, one to hold a full-size photo, the other for a thumbnail image. I want to populate both columns at the same time. At the moment I'm uploading just the photo:

SET @sql = 
'INSERT INTO myTable (Filename, Image) ' +
'SELECT ''' + @Filename + ''' , Photo.* ' + 
'FROM OPENROWSET (BULK ''' + CONVERT(varchar(1000), @Path) + ''', SINGLE_BLOB) Photo'
EXEC sp_executesql @sql	

Open in new window



How do I amend this statement to include the thumbnail file?
0
Comment
Question by:TimHudspith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 43

Accepted Solution

by:
Eugene Z earned 2000 total points
ID: 39908796
try
INSERT INTO myTable (imgid,imgname,fsImg,tnImg)

select
NEWID(),
'imgname',
bulkcolumn
FROM OPENROWSET(BULK 'C:\img\fsphoto.gif', SINGLE_BLOB) AS A,
bulkcolumn
FROM OPENROWSET(BULK 'C:\img\TNphoto.gif', SINGLE_BLOB) AS B,
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

762 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