Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > 两个简单的分页SQL过程
【标  题】:两个简单的分页SQL过程
【关键字】:SQL
【来  源】:http://blog.csdn.net/badyue/archive/2007/02/17/1511490.aspx

两个简单的分页SQL过程

Your Ad Here


create proc Page
(
@PageIndex int
)
as
declare @page int
declare @sql varchar(1000)
set @page=@PageIndex*5
set @sql=
'select top 5 Brand.BrandID,Brand.BrandName,Brand.HtmlUrl,Brand.TypeID,Brand.LogoUrl2,Brand_Type.BrandTypeName
from
Brand,Brand_Type
where
convert(int,substring(Brand.TypeID,2,1))=Brand_Type.BrandTypeId
and Brand.BrandID
in
(
select top '+str(@page)+' BrandID
from
Brand
order by UpdateDate Desc
)
and Brand.BrandID
not in
(
select top '+str(((@PageIndex-1)*5))+' BrandID
from
Brand

order by UpdateDate Desc
)
order by UpdateDate Desc'
exec(@sql)
  


create proc GetBrandBBS
@PageIndex int,
@BrandID int
as
declare @SQL Varchar(500)
begin
Set @SQL='select top 4 [ID],BrandID,Title,Content,UserName,Address,AddDate
from Brand_BBs 
where BrandID='+str(@BrandID)+'
and [ID]
in
(select top '+str(4*(@PageIndex))+' [ID] from Brand_BBs where BrandID='+str(@BrandID)+' order by [ID] desc)
and [ID]
not in
(select top '+ str(((@PageIndex-1)*4)) +' [ID]  from Brand_BBS where BrandID='+str(@BrandID)+' order By [ID] desc)
order by [ID] desc'
end

exec (@SQL)

BI解决方案-数据仓库的设计:【上一篇】
用存储过程生成单据号:【下一篇】
【相关文章】
  • MySQL5.0学习笔记_01
  • 架设freeradius+mysql的radius服务器
  • 导出sql server 数据库为Excel的数据字典的小工具
  • Oracle SQLCODE/SQLERRM
  • sql plus 技巧
  • 开源嵌入式数据库Bericeley DB和SQLite的比较
  • SQL Server 2005从入门到精通 -- 学习笔记1 -- 数据库中选择储存哪些应用程序数据
  • VS2005中使用MySQL 5.0
  • MS SQL Server 2005 开发之分页存储过程
  • MSSQL 错误对照表
  • 【随机文章】
  • Awk 编程学习笔记之二
  • 解除网吧限制
  • ASP.NET 2.0 中 Web 事件
  • 特洛伊木马病毒“黑洞”分析报告
  • 天堂2 关于二刀流
  • 关于广州.NET俱乐部的logo和T恤设计以及往后安排
  • XmlHttp是什么?
  • 用WM_COPYDATA传递struct
  • Parallax Mapping
  • C语言函数速查
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.