Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Insert data into table The results of stored procedure Expand / Collapse
Author
Message
Posted Thursday, October 7, 2010 1:32 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, February 4, 2011 1:22 AM
Points: 15, Visits: 42
Hi All,
i have 3 stored procedures give results as below.
1.sp oupput: servername,edition,level
2.sp2 output : databasename,allocated size,freesize
3.sp3 output : databasename,username,role

now i would like to move all these results in one table
Can i know how to insert data into one table (the database name) should come in one column.

Thanks in advance,
popuri.
Post #1000159
Posted Thursday, October 7, 2010 1:59 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 9:44 AM
Points: 3,959, Visits: 5,194
To begin with, the results of each of the procedures will need to be inserted into their own tables.
CREATE TABLE #FirstOutput (ServerName SYSNAME, Edition NVARCHAR(256), [Level] NVARCHAR(26))
CREATE TABLE #SecondOutput (DatabaseName SYSNAME, Allocated_Size INT, FreeSize INT)
CREATE TABLE #ThirdOutput (DatabaseName SYSNAME, UserName NVARCHAR(256), [Role] NVARCHAR(26))

INSERT #FirstOutput
EXEC storedProc1
INSERT #SecondOutput
EXEC storedProc2
INSERT #ThirdOutput
EXEC storedProc3


From that point further, use these tables as the source of the final insert.



____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1000174
Posted Thursday, October 7, 2010 2:41 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 9:44 AM
Points: 3,959, Visits: 5,194
Point of note:
this will only work provided the procedures being executed do not use the "INSERT INTO ... EXEC" syntax within themselves


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1000193
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse