[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

INSERT INTO EXEC WITH RESULT SETS

Posted on 2013-01-30
4
Medium Priority
?
600 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

834 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