|
Question : Using Stored Procedure
|
|
Hi Xperts
For executing a Stored Procedure I could use < Exec my_sp '1','2' >. Can I use the StoredProcedure to retrieve inside a query as like i execute a subquery? Like < select * from (select * from Tbl1) as Table_1 >. Instead of the subquery (Select * from Tbl1), How can I execute an SP inside it? Is it possible?
Thanks in Advance
|
|
Answer : Using Stored Procedure
|
|
Create a Function to do this...
I think what I hear you say is
-- A Very simple example... CREATE FUNCTION [dbo].[fnCalculateSum] ( @A int, @B int ) RETURNS int AS BEGIN
DECLARE @Sum int
SET @Sum = @A + @B
RETURN (@Sum) END GO
-- Your Query SELECT ValueA, ValueB, dbo.fnCalculateSum(ValueA, ValueB) FROM Table
|
|
|
|