Monday 16 July 2012

How to use out key word in stored procedure in sql



creating database test 
create database test

after creating database ,create table  Customer in database test

use  test

create table customer (id int primary key IDENTITY(1,1),Name varchar(50),FatherName nvarchar(50))


 creating  procedure with out keyword int_customer  for Customer table */

create proc int_customer @Name varchar(50),@FatherName nvarchar(50),@id int out
as
begin
insert into customer values(@Name,@FatherName)
set @id=@@identity
end

executing procedure for int_customer data in Customer table */

declare @id int
exec int_customer 'Varun','Dev',@id out
select @id as Id





0 comments:

Post a Comment