CREATE PROCEDURE page
@intPageNum int,
@intPageSize int,
@strTable varchar(500),
@strwhere varchar(500),
@id varchar(500)
AS
IF(@intPageNum<=1)
(select ceiling((count(*)+0.0)/@intPageSize) as tb from @strTable where @strwhere)
SELECT TOP @intPageSize *
FROM @strTable
WHERE @strwhere
IF((SELECT CEILING((COUNT(*)+0.0)/@intPageSize) FROM @strTable WHERE @strwhere)>1)
SELECT CEILING((COUNT(*)+0.0)/@intPageSize) FROM @strTable WHERE @strwhere
SELECT TOP @intPageSize *
FROM @strTable
WHERE @id>
(
SELECT MAX(@id)
FROM (
SELECT TOP @intPageSize*@intPageNum-1 @id
FROM @strTable
WHERE @strwhere
order by @id)
as t )
AND @strwhere
order by @id
ELSE
(select ceiling((count(*)+0.0)/@intPageSize) as tb from @strTable where @strwhere)
SELECT TOP @intPageSize *
FROM @strTable
WHERE @strwhere哪位高手知道这个对吗!!!!
@intPageNum int,
@intPageSize int,
@strTable varchar(500),
@strwhere varchar(500),
@id varchar(500)
AS
IF(@intPageNum<=1)
(select ceiling((count(*)+0.0)/@intPageSize) as tb from @strTable where @strwhere)
SELECT TOP @intPageSize *
FROM @strTable
WHERE @strwhere
IF((SELECT CEILING((COUNT(*)+0.0)/@intPageSize) FROM @strTable WHERE @strwhere)>1)
SELECT CEILING((COUNT(*)+0.0)/@intPageSize) FROM @strTable WHERE @strwhere
SELECT TOP @intPageSize *
FROM @strTable
WHERE @id>
(
SELECT MAX(@id)
FROM (
SELECT TOP @intPageSize*@intPageNum-1 @id
FROM @strTable
WHERE @strwhere
order by @id)
as t )
AND @strwhere
order by @id
ELSE
(select ceiling((count(*)+0.0)/@intPageSize) as tb from @strTable where @strwhere)
SELECT TOP @intPageSize *
FROM @strTable
WHERE @strwhere哪位高手知道这个对吗!!!!
非常感谢!这个非常重要!