Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Insert data into table The results of stored procedure


Insert data into table The results of stored procedure

Author
Message
syamala.popuri
syamala.popuri
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
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.
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5812 Visits: 7140
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”
Stewart "Arturius" Campbell
Stewart "Arturius" Campbell
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5812 Visits: 7140
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”
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search