Different Types of SQL Parameters in stored Proc

There are basically three types of parameters while dealing with stored proc 

1.INPUT Parameter( in short-IN)
2.OUTPUT Parameter( in short -OUT)
3.INPUTOUTPUT Parameter ( inshort--INOUT)

Consider the INPUT Parameter first with an example

CREATE PROCEDURE get_something
   @city varchar(50)  /*Note: by default we can leave the word IN blank */
 as
Select firstname,lastname from Details
where locationofcity=@city 

exec get_something 'Jacksonville
'

This statement will result into a table with firstname and lastname for the city jacksonville

Now lets Consider the OUTPUT Parameter with an example

The word OUTPUT here basically indicates that this will return some value . it is something GET  

CREATE PROCEDURE findsomething

@NumberOne int,
@Numbertwo int,
@Result int OUT

AS

SET @Result=@NumberOne-@Numbertwo
GO

Declare @Result int
EXEC findsomething 
5,
3,
@Result out
Print @Result

Consider the INPUTOUTPUT Parameter first with an example

section soon to be added

No comments:

Post a Comment