Parameters Used with Stored Procedures

Parameters enable you to write flexible stored procedures by executing the SQL statements with values that are determined at runtime (not at compile time) and that can be changed at every execution. Parameters follow the same naming conventions as standard stored procedure variables. (They must begin with @.) Parameters can be input parameters or output parameters.

Input Parameters

Input parameters are used to pass values into a stored procedure. Input parameters have the following syntax:

Create proc Procedure_name @parm1 datatype, @paramN datatype 

The following example defines three input parameters of different data types:

 Create procedure usp_input @temp_name varchar(30), @total int, @current_date ...

Get Microsoft® SQL Server™ 2000 DBA Survival Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.