惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
V
V2EX
Cloudbric
Cloudbric
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
量子位
博客园 - 三生石上(FineUI控件)
博客园 - 叶小钗
K
Kaspersky official blog
博客园 - 【当耐特】
T
Tenable Blog
L
Lohrmann on Cybersecurity
The Cloudflare Blog
S
Schneier on Security
A
Arctic Wolf
Latest news
Latest news
C
Cyber Attacks, Cyber Crime and Cyber Security
罗磊的独立博客
T
The Exploit Database - CXSecurity.com
Cisco Talos Blog
Cisco Talos Blog
小众软件
小众软件
P
Privacy & Cybersecurity Law Blog
WordPress大学
WordPress大学
Simon Willison's Weblog
Simon Willison's Weblog
雷峰网
雷峰网
NISL@THU
NISL@THU
人人都是产品经理
人人都是产品经理
月光博客
月光博客
J
Java Code Geeks
V
Visual Studio Blog
S
Security Affairs
博客园 - Franky
T
Tailwind CSS Blog
Apple Machine Learning Research
Apple Machine Learning Research
H
Heimdal Security Blog
有赞技术团队
有赞技术团队
V2EX - 技术
V2EX - 技术
AWS News Blog
AWS News Blog
G
GRAHAM CLULEY
T
Troy Hunt's Blog
SecWiki News
SecWiki News
Spread Privacy
Spread Privacy
宝玉的分享
宝玉的分享
www.infosecurity-magazine.com
www.infosecurity-magazine.com
博客园 - 聂微东

博客园 - 共同学习,共同进步

SQL Pretty Printer for SSMS 很不错的SQL格式化插件 GOOD LINK C# 代码片段 用简单代码破解Excel保护密码 罗克韦尔自动化(中国)责任有限公司 - 招聘软件开发实习生 思考1 NET Framework Library Source Code Now Available SQL IsEmptyOrNull [笔记] C# 3.0 新特性[3]-Understanding Object Initializers [笔记] C# 3.0 新特性[2]-Understanding Extension Methods [笔记] C# 3.0 新特性[1]-implicitly typed local variables listview and downloader TFS 2008 - Running two Build Agents on the Same Machine Team Foundation Blog Overview of Team Foundation Build Understanding CGI with C# IEnumerator 是所有非泛型枚举数的基接口 C# Programming Guide An Introduction to C# Generics
通用数据库存储过程代码--高效分页存储过程
共同学习,共同进步 · 2008-01-15 · via 博客园 - 共同学习,共同进步

-- 获取指定页的数据 
Create PROCEDURE pagination
    
@tblName varchar(255), -- 表名 
    @strGetFields varchar(1000= '*'-- 需要返回的列 
    @fldName varchar(255)=''-- 排序的字段名 
    @PageSize int = 10-- 页尺寸 
    @PageIndex int = 1-- 页码 
    @doCount bit = 0-- 返回记录总数, 非 0 值则返回 
    @OrderType bit = 0-- 设置排序类型, 非 0 值则降序 
    @strWhere varchar(1500= '' -- 查询条件 (注意: 不要加 where) 
AS 

declare @strSQL varchar(5000-- 主语句 
declare @strTmp varchar(110-- 临时变量 
declare @strOrder varchar(400-- 排序类型 
if @doCount != 0 
    
begin 
        
if @strWhere !='' 
            
set @strSQL = "select count(*as Total from [" + @tblName + "] where "+@strWhere 
        
else 
            
set @strSQL = "select count(*as Total from [" + @tblName + "]
    
end 
    
--以上代码的意思是如果@doCount传递过来的不是0,就执行总数统计。以下的所有代码都是@doCount为0的情况 

else 
    
begin 
        
if @OrderType != 0 
            
begin 
                
set @strTmp = "<(select min
                
set @strOrder = " order by [" + @fldName +"] desc
                
--如果@OrderType不是0,就执行降序,这句很重要! 
            end 
        
        
else 
            
begin 
                
set @strTmp = ">(select max
                
set @strOrder = " order by [" + @fldName +"] asc
            
end 
            
if @PageIndex = 1 
                
begin 
                    
if @strWhere != '' 
                        
set @strSQL = "select top " + str(@PageSize+" "+@strGetFields+ " from [" + @tblName + "] where " + @strWhere + " " + @strOrder 
                    
else 
                        
set @strSQL = "select top " + str(@PageSize+" "+@strGetFields+ " from ["+ @tblName + "] "+ @strOrder 
                        
--如果是第一页就执行以上代码,这样会加快执行速度 
                end 
            
else 
                
begin 
                    
--以下代码赋予了@strSQL以真正执行的SQL代码 
                    set @strSQL = "select top " + str(@PageSize+" "+@strGetFields+ " from [
                        + @tblName + "
] where [" + @fldName + "]+ @strTmp + "(["+ @fldName + "]from (select top " + str((@PageIndex-1)*@PageSize+ " ["+ @fldName + "] from [" + @tblName + "]+ @strOrder + ") as tblTmp)"+ @strOrder 
                        
if @strWhere != '' 
                    
set @strSQL = "select top " + str(@PageSize+" "+@strGetFields+ " from [
                        + @tblName + "
] where [" + @fldName + "]+ @strTmp + "([
                        + @fldName + "
]from (select top " + str((@PageIndex-1)*@PageSize+ " [
                        + @fldName + "
] from [" + @tblName + "] where " + @strWhere + " " 
                        
+ @strOrder + ") as tblTmp) and " + @strWhere + " " + @strOrder 
    
end 
end 


exec (@strSQL)
GO

Dynamic Sql

Code