+ -
当前位置:首页 → 问答吧 → 存储过程

存储过程

时间:2011-12-14

来源:互联网

SQL code
  create proc [color=#FF0000]GetCounty[/color]
  @startIndex int,
  @endIndex int
  as
  with 日志表 as (select row_number() over(order by o_id) as rowIndex,* from [color=#FF0000]County[/color])
  select * from 日志表 where rowIndex between @startIndex and @endIndex
  go

  这个是想做的真分页,谁能帮我解释下County
原代码
SQL code
create procedure sp_Paging_GetCounty

@startIndex int,

@endIndex int

as

with table_temp as (select row_number() over(order by o_id) as rowIndex,* from County)

select * from table_temp where rowIndex between @startIndex and @endIndex

go

作者: hy63171234   发布时间: 2011-12-14

County?
查询的表呗!

作者: qianjin036a   发布时间: 2011-12-14

引用 1 楼 qianjin036a 的回复:
County?
查询的表呗!

我放的表但是说是无效的

作者: hy63171234   发布时间: 2011-12-14

你放这个存储过程的数据库中,有这个County 表吗?

作者: qianjin036a   发布时间: 2011-12-14

引用 3 楼 qianjin036a 的回复:
你放这个存储过程的数据库中,有这个County 表吗?

SQL code
create procedure sp_Paging_GetCounty

@startIndex int,

@endIndex int

as

with table_temp as (select row_number() over(order by o_id) as rowIndex,* from County)

select * from table_temp where rowIndex between @startIndex and @endIndex

go

你能帮我详细解释下这个么 每个都代表什么

作者: hy63171234   发布时间: 2011-12-14

County就是查询表

没看到哪有问题 ...

作者: ju523756055   发布时间: 2011-12-14

语句的语法没有问题的,关键的此数据库中是否有此表还有一个可能把存储过程建到别的库中了。

作者: lzd_83   发布时间: 2011-12-14

引用 6 楼 lzd_83 的回复:
语句的语法没有问题的,关键的此数据库中是否有此表还有一个可能把存储过程建到别的库中了。


嗯 
第一句是 创建了个临时表(多加了个行号)
第二句是 查询这个临时表

作者: ju523756055   发布时间: 2011-12-14

引用 7 楼 ju523756055 的回复:
引用 6 楼 lzd_83 的回复:
语句的语法没有问题的,关键的此数据库中是否有此表还有一个可能把存储过程建到别的库中了。



第一句是 创建了个临时表(多加了个行号)
第二句是 查询这个临时表

懂了谢谢

作者: hy63171234   发布时间: 2011-12-14

SQL code
楼主是想让解释一下这个语句的意思。还是怎的
----创建一个存储过程名为 sp_Paging_GetCounty
create procedure sp_Paging_GetCounty
---声明变量 
@startIndex int,

@endIndex int

as
----创建一个重新生成一列rowindex临时表table_temp
with table_temp as (select row_number() over(order by o_id) as rowIndex,* from County)
---根据条件查询临时表
select * from table_temp where rowIndex between @startIndex and @endIndex

go

作者: lzd_83   发布时间: 2011-12-14

引用 9 楼 lzd_83 的回复:
SQL code

楼主是想让解释一下这个语句的意思。还是怎的
----创建一个存储过程名为 sp_Paging_GetCounty
create procedure sp_Paging_GetCounty
---声明变量
@startIndex int,

@endIndex int

as
----创建一个重新生成一列rowindex临时表table_temp
wit……

over(order by o_id)
这个o_id 是County 的主键字段还是新表table_temp 的字段

作者: hy63171234   发布时间: 2011-12-14

over(order by o_id)
这里的o_id是表County里的字段.是不是主键字段这要是看楼主的表是怎么设计的了

作者: chenguang79   发布时间: 2011-12-14