Hi
How to create a stored procedure in sqlserver to return value by taking input parameter..
How to create a stored procedure in sqlserver to return value by taking input parameter
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Krishna GaradRank #191 · 12.8K reputationPosted Nov 29, 2011, 9:33 PM EST
(
@para1 datatype,
@para2 Datatype out
)
As
Begin
Set @para2=(value)
End
Pravin MoreRank #1,419 · 1.2K reputationPosted Nov 29, 2011, 9:58 PM EST
Hi Akila,
here is sample for it....
create PROCEDURE [dbo].[GetValueONID]
@ID INT AS
BEGIN
SET NOCOUNT ON
select p.Amount from Product p where p.productID=@ID
END
Thanks,
Pravin.
Datta KharadRank #2,135 · 668 reputationPosted Nov 29, 2011, 10:15 PM EST
Creating dynamic stored proceudre to return value by taking input parameter.
CREATE OR REPLACE PROCEDURE
UP_SELECTSP (
selColName IN VARCHAR, --selColName is used for selecting single column or multiple columns
TableName IN VARCHAR, --TableName is used for providing Table Name
whrCondition IN VARCHAR, --whrCondition is used for provide where condition
getResult_Cur OUT SYS_REFCURSOR --getResult_Cur is used for returning result set
)
AS
strSQL varchar(1000);
BEGIN
IF whrCondition is not null then
strSQL := 'SELECT ' || selColName || '
FROM ' || TableName || '
WHERE ' || whrCondition || '';
ELSE
strSQL := 'SELECT ' || selColName || '
FROM ' || TableName || '';
END IF;
OPEN getResult_Cur FOR strSQL;
END UP_SELECTSP;