BEGIN DECLARE @START_ID NVARCHAR(50) DECLARE @END_ID NVARCHAR(50) SET @START_ID = convert(NVARCHAR(50),(@PageIndex - 1) * @PageSize + 1) SET @END_ID = convert(NVARCHAR(50),@PageIndex * @PageSize) SET @strsql = ' SELECT '+@Column+ ' FROM (SELECT ROW_NUMBER() OVER(ORDER BY '+@Sort+') AS RowNum, '+@Column+ ' FROM '+@Table +' WITH(NOLOCK) ' + @strWhere +') AS D WHERE RowNum BETWEEN '+@START_ID+' AND ' +@END_ID +' ORDER BY '+@Sort END EXEC(@strsql) SET @strsql = 'SELECT Count(1) as TotalRecords FROM ' + @Table +' WITH(NOLOCK) ' + @strWhere EXEC(@strsql)
执行这个存储过程之后,它会在我原来表字段后面多显示一列为"RowNum"的字段。不知如何去掉这个字段,让它不显示出来?
在筛选出来的结果集上,再筛选一次就行了