sql server (存储过程,事务)联系

  --删除存储过程删除特定表中的一条记录---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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值