August 22, 2010 at 11:41 pm
Hi,
I have a sub procedures , it contains
two insertions & update query finall i have a select column1,column 2 from table name
In main procedures am calling & i want o store the ,column 1 & column 2 in two temp variable ,
Is it possible ?
August 23, 2010 at 12:16 am
Yes you are.
You need to create temp table & use it to store the return resultset of stored procedure.
CREATE TABLE #tempTable
(Col1 NVARCHAR(MAX),
Col2 NVARCHAR(MAX)
)
INSERT INTO #tempTable
EXEC procSample;
Hope sample will resolve your problem.
Thanks
August 23, 2010 at 12:18 am
If you expect to select only one value for each column, I would recommed you to use OUT variables.
However, if there can be multiple values, then the above solution is correct except one thing, use table variable instead of temp table.
Thanks,
Garima
August 23, 2010 at 12:23 am
Temp table is useful, if you want to supply the same table/data in the next calling procedure in the hierarchy.
Thanks
August 23, 2010 at 12:39 am
THank u ...
August 23, 2010 at 1:30 am
Sorry for incon.
If i tried with this format not working
SELECT * INTO ##TEMP
FROM
T_SP_UPDATE_ITEM_DETAILS '139',30,'TB'
Error
Msg 102, Level 15, State 1, Line 3
Incorrect syntax near '139'.
please tell me
August 23, 2010 at 1:35 am
You cannot use 'select * into #temp from exec SPname'.
You will have to create the temp table first and then use insert statement with execute SP to add the result set of SP to temp table.
Thanks,
Amit kulkarni
August 23, 2010 at 1:37 am
Instead of
SELECT * INTO ##TEMP
FROM
T_SP_UPDATE_ITEM_DETAILS '139',30,'TB'
write
SELECT * INTO ##TEMP
EXEC T_SP_UPDATE_ITEM_DETAILS '139',30,'TB'
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply