--切换到db_StuManagement数据库
use db_StuManagement
go
--分页查询
--判断存储过程是否存在
if exists(SELECT * FROM sys.objects where name='proc_PagePaging')
drop proc proc_PagePaging
go
--创建存储过程
create proc proc_PagePaging
--声明参数
@stuNumber varchar(16),
@stuSex int,
@pageIndex int,
@pageSize int,
@tbName varchar(18),
@rowCount int output
as
BEGIN
--声明变量
DECLARE @sqlStr nVARCHAR(500)
SET @sqlStr='select * from '+@tbName+' where 1=1 '
DECLARE @whereStr nVARCHAR(500)
SET @whereStr=''
print @sqlStr
--添加学生学号查询条件
IF(@stuNumber!='' AND @stuNumber IS NOT NULL)
BEGIN
SET @whereStr=' and stuNumber LIKE ''%'+@stuNumber+'%'''
END
--添加学生性别查询条件
IF(@stuSex IS NOT NULL)
BEGIN
SET @whereStr+=' and stuSex='+cast(@s
SQL Server 存储过程 分页、条件查询2019/08/01 18:172019/08/01 18:17--切换到db_StuManagement数据库use db_StuManagementgo--分页查询--判断存储过程是否存在if exists(SELECT * FROM sys.objects where name='proc_PagePaging')drop...