Solved

INSERT INTO EXEC WITH RESULT SETS

Posted on 2013-01-30
4
534 Views
Last Modified: 2013-03-17
I wish to use the Result Sets with EXEC and Wanted ton insert Result Set in to Temp table.


CREATE TABLE #TEMP
(
Col1 nvarchar(50)
)
INSERT INTO #TEMP 
EXEC [dbo].[usp_GetProjectByEmployeeNo] @EmployeeNo = N'9999'
WITH RESULT SETS
((
Col1 nvarchar(50)
));
GO

Open in new window


I am getting error "Incorrect syntax near SETS"
0
Comment
Question by:Alpesh Patel
  • 2
4 Comments
 
LVL 10

Expert Comment

by:deviprasadg
ID: 38838337
The RESULT SETS options cannot be specified in an INSERT…EXEC statement

Refer: http://msdn.microsoft.com/en-us/library/ms188332(SQL.110).aspx

Also you can accomplish your task by removing the with result sets section from the above query.

CREATE TABLE #TEMP
(
Col1 nvarchar(50)
)
INSERT INTO #TEMP 
EXEC [dbo].[usp_GetProjectByEmployeeNo] @EmployeeNo = N'9999'

Open in new window

0
 
LVL 51

Expert Comment

by:Mark Wills
ID: 38839067
Correct, you do not use the result sets.

Given the current use of RESULT SETS then the SP is currently returning a single column that matches the Temp Table.

Result Sets in that case are a good reminder of the output.

However, worth remembering, your temp table will need to accomodate the entire result, it wont automatically concatenate into one column.

So, if you stored procedure returned : ProjectID, ProjectName, DueDate
then your Temp Table needs to be able to store those three columns.
0
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 0 total points
ID: 38977493
I am closing the Question by selecting my answer because, I have the same knowledge as provided by "deviprasadg".
0
 
LVL 21

Author Closing Comment

by:Alpesh Patel
ID: 38993061
I am closing the Question by selecting my answer because, I have the same knowledge as provided by "deviprasadg".
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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.

828 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