????????洢???????
?????洢?????????????ж?????????????е????????SQL???
??????????????洢??????????????????????????SQL???
????????????洢???????
????1.?洢??????????????б???????????д洢??????????????±????????SQL?????????α?????Σ????????洢????????????????????
????2.???????????и??????????????????????洢??????????????????????????????????á?
????3.?洢??????????????????????????????????????
????4.??????????趨????Щ???????ж?????洢?????????
??????洢????????????
?????????????Student ?????洢??????????????洢???????÷?????????????????????
????SQL Server??洢?????????
??????????洢?????
???????Student???е??????????
????create proc StuProc
????as //??? as ??????????д
????begin //begin ?? end ?????????????д??????????????????д
????select S#??Sname??Sage??Ssex from student
????end
????go
?????в????洢?????
??????????
???????????????????????????????????????????????????????????崦???????????????????β??
??????????????????????:
????create proc StuProc
????@sname varchar(100)
????as
????begin
????select S#??Sname??Sage??Ssex from student where sname=@sname
????end
????go
????exec StuProc '????' //??????
???????????????????????????????????????????????????
????create proc StuProc
????@sname varchar(100)='????'
????as
????begin
????select S#??Sname??Sage??Ssex from student where sname=@sname
????end
????go
????exec StuProc
???????????????????????????output
????create proc StuProc
????@sname varchar(100)??
????@IsRight int output //????????
????as
????if exists (select S#??Sname??Sage??Ssex from student where sname=@sname)
????set @IsRight =1
????else
????set @IsRight=0
????go
????declare @IsRight int
????exec StuProc '????' ?? @IsRight output
????select @IsRight
?????????????????????????????????
?????????????????????????????????????????????????????????????????????????ú????????????????????????
???????????????壺????????Declare???????????????declare{@?????? ????????}
?????????????????????set{@??????=????}????select{@??????=????}
??????????????????select @??????
????create proc StuProc
????as
????declare @sname varchar(100)
????set @sname='????'
????select S#??Sname??Sage??Ssex from student where sname=@sname
????go
????exec StuProc
???????????????????????????????????????
????create proc StuProc
????as
????declare @sname varchar(100)
????set @sname=(select Sname from student where S#=01)
????select @sname
????go
????exec StuProc