------------------------带参数的存储过程--------------
--从result,student表中查询成绩大于60分的学生的 姓名和成绩
--及格线会调整
create procedure usp_unpass
@score int
as
if(@score<0 or @score>100)
begin
print '错'
end
else
begin
select StudentName,StudentResult
from Student as a,Result as v
where a.studentNo=v.studentNo
and studentresult>@score
end
exec usp_unpass 80
go
------------------------------带out参数的存储过程-----------------------------------
--分页存储 过程
--每页条数据
--查询第二页的数据 4-6
create procedure usp_GetPageListS2226
@pageIndex int,--第几页
@pagesize int,--页大小呢
@totalRecords int out,--总记录数
@totalPages int out--总页数
as
select @totalRecords=count(1) from student
select * from
(
select * ,row_number() over(order by studentno) as myid
from student
) as temp
where myid between (@pageIndex-1)*@pagesize+1 and @pageIndex*@pagesize
declare @record int
declare @page int
exec usp_GetPageListS2226 2,3,@record out,@page out
print @record
print @page
---------------------------------------------------------------------------------
--互联网是非常危险的(专门攻击他人电脑,肉鸡)。
--小孩们不要随意接触互联网
--1.什么是存储过程?
--就是在数据库服务器上保存的一对预编译(:驻留SQL Server服务器的内存中。。。)的SQL
--1.1存储过程分类
--3类: 用户自定义存储过程(*****)usp_
-- 系统存储过程(sp_System PROCEDURE)
-- 扩展存储过程(xp_extends procedure)
--2.如何使用存储过程
go
create procedure usp_StudentInfo
as
--增删改,,也可以是查询
select * from student
--------------------------------------------------
--new 三件事
--1:创建对象
--2.调用构造函数
--3.开辟空间
---------------------------------
--EXEC sp_helpIndex name
--EXEC sp_helpIndex Result
--SELECT * FROM sys.indexes
--USE MySchool
--SELECt * FROM sys.indexes