2 maosun5918 maosun5918 于 2017.08.29 11:37 提问

存储过程进行排序,求大神解决Bug

alter procedure usp_StudentInfoDataByPage
@pageIndex int=1,--当前页
@pageSize int=5,--页面显示数据数
@Count int output,--数据总条数
@action varchar(20)--排序字段
as
begin
with t as(
select ,Row_number() over(order by gKey) as Id from StudentScore)
---------查询数据记录------------
select
t.gKey,
gStudentKey,
sName,
iSubjects,
dScore,
iSemester
from t
join StudentInfo on t.gStudentKey=StudentInfo.gKey
where t.Id between (@pageIndex-1)
@pageSize+1 and @pageIndex*@pageSize
order by
case
when @action='gStudentKey' then gStudentKey
when @action='iSubjects' then iSubjects
when @action='iSemester' then iSemester
else t.gKey --cast(t.gKey as int)
end
---------查询数据记录总条数------------
set @Count= (Select Count(*) from StudentScore)
end
图片说明

1个回答

maosun5918
maosun5918   2017.08.29 11:41

图片说明

Csdn user default icon
上传中...
上传图片
插入图片