I have been using stored procedure for more than 1.5 years. But I never thought how data is retrieved from UI or within another stored procedure.
When I writes a simple stored procedure. eg.
CREATE PROCEDURE sp_test
AS
BEGIN
SELECT * FROM tblTest --Considering table has 3 columns.
END
How does C# gets this result into DataTable.
Whenever I have to use the result of this procedure into another procedure. I think we have to create a table valued parameter using table datatype and assign its result into table variable. I never tried it.
CREATE PROCEDURE sp_testcall
AS
BEGIN
@temp = exec sp_test -- I think this would be the way, never tried
END
If above sample code is true, then what is the difference between using above method and Query to insert records into temporary table.
CREATE PROCEDURE sp_test
AS
BEGIN
SELECT * INTO #tmp FROM tblTest --Considering table has 3 columns.
END
Since copying result into temporary table needs an another effort by sql server to do. But what would be going behind. Would it directly assigns reference of result into table valued parameter or do the same process as done by temporary table.
I might not be clear to you in my question. But will try to improve.