Solved

Using OPENROWSET twice in one SQL statement

Posted on 2014-03-05
1
370 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 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.

738 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