create PROCEDURE [dbo].[page]
@startIndex int,
@endIndex int,
@Count int out
AS
BEGIN
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY productid desc)AS Row,
* from A
)
SELECT * FROM temptbl where Row between @startIndex and @endIndex
select @Count =count(1) from a
END
godeclare @count int
exec page 1,2,@count out
print @count
/*
Row productid salecount
-------------------- ----------- -----------
1 125 3
2 124 6(2 行受影响)4
*/
解决方案 »
- 随机取出不重复的数字做为ID批量插入一张表中要怎么实现
- 怎么把sql2000的数据库中的数据导入到sql2005的数据库中
- 如何将数据库的设计结构用SQL语句提取出来保存在一个.sql文本文件中,然后运行这个文本文件重新生成一个新的空数据库,且与原来的数据库结构完全一样。
- 紧急求助!!!update时忘记加where
- sql作业运行问题
- 一个综合查询的问题,一点点难度
- 想用ado取得视图和存储过程的sql代码,各位有何高招?
- sqlserver2005中插入中文成乱码的问题??
- isnull()函数的问题!
- sql 2008 安装的时候,点setup,闪一下就没了 求大神!
- 怎么根据时间字段值返回最新的记录,要求按Simnum字段分组统计
- 请高手指教: sql server 2005 远程连接问题
create PROCEDURE [dbo].[page]
@startIndex int,
@endIndex int,
@Count int out
AS
BEGIN
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY productid desc)AS Row,
* from A
)
SELECT * FROM temptbl where Row between @startIndex and @endIndex
select @Count =count(1) from a
END
godeclare @count int
exec page 1,2,@count out
print @count
/*
Row productid salecount
-------------------- ----------- -----------
1 125 3
2 124 6(2 行受影响)4
*/
USE [Water]
GO
/****** Object: StoredProcedure [dbo].[Admin_SelectAll] Script Date: 03/05/2009 12:35:00 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 牛腩
-- Create date: 20090302 14:31
-- Description: 选择全部管理员记录
-- =============================================
ALTER PROCEDURE [dbo].[Admin_SelectAll]
@startIndex int,
@endIndex int
AS
BEGIN SELECT ROW_NUMBER() OVER (ORDER BY id desc)AS Row,
ID,Name,Password,[Rank],CreateTime
into #temptbl
from AdminSELECT * FROM #temptbl where Row between @startIndex and @endIndex
--计算记录数
declare @count int
select @count=count(ID) from #temptbl
drop table #temptbl
return @count
END