Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear sir

Can store procedure return table

please explain with example
Posted

No SPs can not return table.

to 'Return' is different and 'Result Set' is different, whatever the values are returned from a select query inside the SP is not return value.

SP can have only one value as return type, it can not be table.

but UDF's can return defined/undefined tables.

thats why we can not use SP inside our select statement but we can use functions (UDFs) in it.

read more details at the given link.

http://geekswithblogs.net/NewThingsILearned/archive/2008/09/17/get-return-value-from-stored-procedure.aspx[^]
 
Share this answer
 
yes, it can.

simple example is:

SQL
CREATE PROCEDURE Test_Proc
AS
BEGIN
 SELECT column_1, column_2 From table_name
END
GO


Above SP will return data from table_name

also check the following article on data returned by Stored procedure:

http://www.sqlteam.com/article/stored-procedures-returning-data[^]
 
Share this answer
 
Comments
stixoffire 14-Dec-16 16:58pm    
No it can't try using the result set in a secondary SQL statement - so call the stored procedure and then try to use those results in the same SQL Statement - using only SQL. No C#, VB, PHP, etc.. you will find it can not.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900