create database test
use test
create table student
(
id int primary key identity(1,1),
stuName varchar(20),
departID int,
totalScore int
)
insert into student(stuName,departID,totalScore) values ('王五',1,88)
select * from student
select * from student where departID=1
/* 简单存储过程*/
create procedure pro_student
as
select * from student where departID=1
go
exec pro_student
/* 带输入参数的存储过程*/
create procedure pro_student1
@departId int
as
select * from student where departID=@departId
go
exec pro_student1 @departID=1
/* 带输入输出参数的存储过程*/
create procedure pro_student2
@departID int,@countNum int output
as
set @countNum=(select count(*) from student where departID=@departID)
print @countNum
declare @departID int,@countNum int
set @departID=1
exec pro_student2 @departID,@countNum
use test
create table student
(
id int primary key identity(1,1),
stuName varchar(20),
departID int,
totalScore int
)
insert into student(stuName,departID,totalScore) values ('王五',1,88)
select * from student
select * from student where departID=1
/* 简单存储过程*/
create procedure pro_student
as
select * from student where departID=1
go
exec pro_student
/* 带输入参数的存储过程*/
create procedure pro_student1
@departId int
as
select * from student where departID=@departId
go
exec pro_student1 @departID=1
/* 带输入输出参数的存储过程*/
create procedure pro_student2
@departID int,@countNum int output
as
set @countNum=(select count(*) from student where departID=@departID)
print @countNum
declare @departID int,@countNum int
set @departID=1
exec pro_student2 @departID,@countNum