--删除存储过程删除特定表中的一条记录---CLASS
USE School
SELECT * FROM Tblstudent
create proc usp_Tblstudent_delete @tSId int
@tSId int
as
begin
delete from Tblstudent where sId=@sId
end
exec usp_Tblstudent_delete @tSId=9
-----修改特定表中的某条记录(更新),这里需要把每一列的值全部传入
select * from class
insert into Class values('Net','优秀班集体')
insert into class values('Java','准优秀班集体')
create procedure usp_Class_update2
@cid int,
@cName varchar(50),
@cDes varchar(50)
as
begin
update class set cName=@cName,cDesciption=@cDes where cId=@cid
end
exec usp_Class_update2 8,'3G','准优秀班集体'
create procedure usp_Class_update1
@cid int,
@cName varchar(50)
as
begin
update class set cName=@cName where cId=@cid
end
exec usp_Class_update1 8,'PHP'
------------查询所有记录的存储过程
create proc usp_class_selectAll
as
begin
select * from Class
end
exec usp_class_selectAll
---实现一个针对特定表的分页的存储过程
select * from
(select *,ROW_NUMBER()over(order by Fid)as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(5*2+1)and 5*3
-------
create proc usp_MyStudent_GetDateByPageIndex
@pageSize int=10,
@pageIndex int
as
begin
select * from
(select *,ROW_NUMBER()over(order by Fid)as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(@pageSize*(@pageIndex-1)+1)and @pageIndex*@pageSize
end
exec usp_MyStudent_GetDateByPageIndex 5,3
USE School
SELECT * FROM Tblstudent
create proc usp_Tblstudent_delete @tSId int
@tSId int
as
begin
delete from Tblstudent where sId=@sId
end
exec usp_Tblstudent_delete @tSId=9
-----修改特定表中的某条记录(更新),这里需要把每一列的值全部传入
select * from class
insert into Class values('Net','优秀班集体')
insert into class values('Java','准优秀班集体')
create procedure usp_Class_update2
@cid int,
@cName varchar(50),
@cDes varchar(50)
as
begin
update class set cName=@cName,cDesciption=@cDes where cId=@cid
end
exec usp_Class_update2 8,'3G','准优秀班集体'
create procedure usp_Class_update1
@cid int,
@cName varchar(50)
as
begin
update class set cName=@cName where cId=@cid
end
exec usp_Class_update1 8,'PHP'
------------查询所有记录的存储过程
create proc usp_class_selectAll
as
begin
select * from Class
end
exec usp_class_selectAll
---实现一个针对特定表的分页的存储过程
select * from
(select *,ROW_NUMBER()over(order by Fid)as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(5*2+1)and 5*3
-------
create proc usp_MyStudent_GetDateByPageIndex
@pageSize int=10,
@pageIndex int
as
begin
select * from
(select *,ROW_NUMBER()over(order by Fid)as rowIndex
from MyStudents)as tb1
where tb1.rowIndex between(@pageSize*(@pageIndex-1)+1)and @pageIndex*@pageSize
end
exec usp_MyStudent_GetDateByPageIndex 5,3