2)
利用上面的数据
create proc dbo.proc_test(@学号 varchar(10))
as
begin
set nocount on
if exists(select 1 from t where 学号=@学号)
select 姓名,性别 from t where 学号=@学号
else
print '查无此人'
end
1)创建一自定义函数FIND,参数为学生的学号,返回值为该生姓名及性别
为什么不建一个procedure呢?
create table t(学号 varchar(10),姓名 varchar(10),性别 varchar(2))
insert into t
select '001','张三','男'
union all
select '002','小花','女'
--select * from t
create proc dbo.proc_test(@学号 varchar(10))
as
begin
set nocount on
select 姓名,性别 from t where 学号=@学号
end