Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

create table MyCustomer_828968(id int IDENTITY(1,1) primary key,name varchar(40)

,contactNo bigint,Location varchar(40));


create proc sp_insertCustomer
(@name varchar(40),
@contactNo bigint,
@Location varchar(40),
@id int out)
as
begin
insert into MyCustomer_828968
values(@name,@contactNo,@Location)
set @id=@@IDENTITY
end
Declare @result int
Execute sp_insertCustomer 'Sivaranjani',9442714102,'Bangalore',@id=@result
print @result
Declare @result int
Execute sp_insertCustomer 'Shridevi',9442714602,'Chennai',@id=@result
print @result
create proc sp_ViewCustomer
as
select * from MyCustomer_828968;
Execute sp_ViewCustomer;
create proc sp_ViewContact
@id int
as
begin
select contactNo from MyCustomer_828968 where id=@id;
end
Execute sp_ViewContact 2
create table NewEmp_828968(id int IDENTITY(101,1) primary key,name varchar(40),D
OB date,salary money);
create proc sp_insertNewCustomer
(@name varchar(40),
@DOB date,
@salary money,
@id int out)
as
begin
insert into NewEmp_828968
values(@name,@DOB,@salary)
set @id=@@IDENTITY
end
Declare @result int
Exec sp_insertNewCustomer 'Muthuvelu','10/07/1955','500000',@id=@result;
print @result
create proc sp_viewNewEmp
as
select * from NewEmp_828968;
Execute sp_viewNewEmp;
create proc sp_EditEmp
@id int,
@DOB date,
@salary money
as
begin
update NewEmp_828968 set DOB=@DOB,salary=@salary
where id=@id
end
Declare @result int
Exec sp_insertNewCustomer 'Sivaranjani','03/27/1955','500000',@id=@result;
print @result
create proc deleteEmp
@id int
as
begin
delete from NewEmp_828968 where id=@id
end
Exec deleteEmp 2
create proc viewByName
@name varchar(40)
as
begin
select * from NewEmp_828968 where name=@name;
end
Exec viewByName 'Sivaranjani';
select * from MyCustomer_828968;

You might also like