select * from TblStudent
--pagecount 总的页数
--count
--页数 5 每页显示几条
--分页的sql语句
declare @count int=(select COUNT(*) from TblStudent)
declare @PageCount int=(CEILING((select COUNT(*) from tblstudent)*1.0/@count))
select * from (select 编号=ROW_NUMBER() over(order by tSid),* from TblStudent ) as t where t.编号
between and
--分页的存储过程
--分页的存储过程
create proc usp_TblStudent
@page int, ---页数
@pageCount int,--条数
@sumPage int output--总页数
as
begin
set @sumPage=Ceiling((select count(*) from TblStudent)/@pageCount*1.0) --总页数
select * from
(select 编号=ROW_NUMBER() over(order by tsid),* from tblstudent)as tstu
where tstu.编号 between (@page-1)*@pageCount+1 and @page*@pageCount
end
declare @c int
exec usp_TblStudent 2,3,@c output
select @c
select top 1 * into newStu from TblStudent
select * from newStu
delete from TblStudent where TSId=1
select * from newStu
insert into TblStudent(TSName,TSGender,TSAddress,TSPhone,TSAge,TSBirthday,TSCardId,TClassId) select TSName,TSGender,TSAddress,TSPhone,TSAge,TSBirthday,TSCardId,TClassId from newStu ---一次性插入多条数据
select * from newStu
select * from TblStudent
--创建一个删除的触发器
create trigger tr_TblStudent on TblStudent
after delete
as
begin
insert into newStu select * from deleted
end
--回出现的错误 仅当使用了列列表并且 IDENTITY_INSERT 为 ON 时,才能为表'newStu'中的标识列指定显式值。
--解决办法 表设计 表示 改成否Ok
select * from newStu
delete from newStu where TSId=1
delete from TblStudent where TSId=2
select * from newStu
select * from newStu
select * from TblStudent
select * from newStu
insert into TblStudent(TSName,TSGender,TSAddress,TSPhone,TSAge,TSBirthday,TSCardId,TClassId) select TSName,TSGender,TSAddress,TSPhone,TSAge,TSBirthday,TSCardId,TClassId from newStu
create trigger tr_TblStudent
select * from tblStudent