How to Use Parameter with Stored Procedure in SQL

In this article I am going to explain about how to declare parameter in stored procedure.
  • 1923

Introduction

In this article I am going to explain about how to declare parameter in stored procedure. We use CREATE PROC statement to create a stored procedure with parameter. We use @ sign to declare a parameter. We put @ sign before parameter name then type of parameter. Type of parameter can be any valid SQL data type.

There are two type of parameter

  • Input parameter
  • Output parameter

Input parameter passed in stored procedure by user at calling time. Output parameter return some value to calling program.

A Statement that create invoices table

Clipboard0111.jpg

Statements that insert data in invoices table

inv (2).jpg

A Statement that is used to fetch data from invoices table

inv.jpg

A Statement that creates a Stored Procedure

Clipboard02.jpg

A Statement that call a Stored Procedure

Clipboard04.jpg

An other way to call a parametrized Stored Procedure

Clipboard08.jpg


© 2013 dotNetheaven. All rights reserved.