Solved

Using OPENROWSET twice in one SQL statement

Posted on 2014-03-05
1
360 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
1 Comment
 
LVL 42

Accepted Solution

by:
EugeneZ earned 500 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

810 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