能不能分页读取?
解决方案 »
- 谁有Aspose.Cells组件将excel导入数据库的例子
- Session变量的清空问题
- 怎么获取数据库字段中的xml中的值
- xml操作错误,那里问题呢?
- 怎么样把url参数一下子全取回来了,然后写入数据库呀?
- 一个奇怪的问题:在asp.net中,encoding是utf-8时,css会失效,如何解决?
- 菜鸟的问题!
- 我想要一条正则表达式,是关于判断有效路径的?(例如:C:\Documents and Settings\Administrator\桌面\test.jpg)谢谢!
- 关于facebook api的问题
- 请问怎样设置DropDownList的样式?
- 我快疯掉了!!!再问asp.net的分析器错误!!!!
- 讨论,关于viewstate与数据处理取舍问题
@pagesize int,
@pageindex intASset nocount on
begin
declare @indextable table(id int identity(1,1),nid int)
declare @PageLowerBound int
declare @PageUpperBound int
set @PageLowerBound=(@pageindex-1)*@pagesize
set @PageUpperBound=@PageLowerBound+@pagesize
set rowcount @PageUpperBound
insert into @indextable(nid) select ID from TbJoin ORDER BY ID DESC
SELECT TbJoin.ID,TbJoin.uid, TbJoin.cal
FROM @indextable t, TbJoin where TbJoin.id =t.nid
and t.id between @PageLowerBound and @PageUpperBound order by t.id end
set nocount off
自己写分页select top 页面记录条数 * from 表 where 记录id>(页数-1)*页面记录条数 order by 记录id
刚才我忘掉orderby了,呵呵
@Author_Last_Name as varchar(100) = null,
@StartRow as int = null,
@StopRow as int = null
AS---- 建立有标识符列的table变量
declare @t_table table
(
[rownum] [int] IDENTITY (1, 1) Primary key NOT NULL ,
[Author_Last_Name] [varchar] (40) ,
[Author_First_Name] [varchar] (20) ,
[phone] [char] (12) ,
[address] [varchar] (40) ,
[city] [varchar] (20) ,
[state] [char] (2) ,
[zip] [char] (5)
)---- 在返回指定的@StopRow行数之后停止处理查询
Set RowCount @StopRow---- 插入到table变量中
insert @t_table
(
[Author_Last_Name],[Author_First_Name],[phone],[address],[city],[state],[zip]
)
SELECT [Author_Last_Name],[Author_First_Name],[phone],[address],[city],[state],[zip]FROM authors
WHERE Author_Last_Name like '%' + @Author_Last_Name + '%'
ORDER BY Author_Last_Name---- 返回到正确的结果
SELECT * FROM @t_table WHERE rownum >= @StartRow
ORDER BY rownumGO