- 4
- 0
- 约7.38千字
- 约 20页
- 2017-06-23 发布于河南
- 举报
两个分页存储过程的效率比较(国外英语资料)
两个分页存储过程的效率比较(国外英语资料)
The efficiency of two paging stored procedures (both for multiple table queries)
-- decryption stored procedures
Exec sp_decryptp_page
Use Newt8c8
Go
If exists (select * from, dbo.sysobjects, where, name=p_page)
Drop procedure p_page
Go
* / / * * paging storage process
Create procedure p_page
(
@Tables varchar (1000) -- table names can be more than one table, but cannot be aliased
@PrimaryKey varchar (100) -- the primary key can be empty, but the value cannot be null when @Order is empty
@Fields varchar (1000) = *, - query field (multiple tables), empty said select *
@PageSize int = 15 -- per page record
@CurrentPage int = 1, - the current page, which represents the first page
@Filter varchar (1000) = null -- condition can be null without filling in where
@Group, varchar (1000) = null, - grouping basis, can be empty, do not fill group by
@Sort varchar (200) = null, - sort, defaults to ascending in the primary key, and does not fill in order by
@TotalPage, int, output -- total pages
)
With encryption - Encryption
As
Set NOCOUNT on
Declare @intResult int
Begin tran
Declare @sql nvarchar (4000)
If, @Filter, is, null, or, @Filter=
Set @Sql =select, @intResult = count (` + @PrimaryKey + ) from + @Tables
Else
Set @Sql =select, @intResult = count (` + @PrimaryKey + ) from + @Tables
+ where + + @Filter
Exec, sp_executesql, @sql, N@intResult, int, output, @intResult, output
Select, @TotalPage=, ceiling ((@intResult+0.0) /@PageSize)
If, @Sort, is, null, or, @Sort =
Set @Sort = @PrimaryKey
Declare @SortTable varchar (100)
Declare @SortName varchar (100)
Declare @strSortColumn varchar (200)
Declare @operator char (2)
Declare @type varchar (100)
Declare @prec int
If CHARINDEX (desc, @Sort) 0
Begin
Set @strSortColumn = replace (@Sort,desc, )
Set @operator ==
End
Else
If CHARINDEX (asc, @Sort) 0
Begin
Set @strSortColumn = replace (@Sort,asc, )
Set @operator ==
End
Else
Begin
Set @strSortColumn = @SORT
Set @operator ==
End
If CHARINDEX (, @strSortColumn) 0
您可能关注的文档
- “四两拨千斤的艺术”--纰谬称计谋之外乡市场造势(国外英语资料).doc
- “国家核心价值与公民文化建设”研讨会综述(国外英语资料).doc
- “最高级别”救市信号来了 基金经理称反弹或超10%(国外英语资料).doc
- “水晶狗肉坊”特色餐馆策划导入记(国外英语资料).doc
- “民工荒”引发人力资源战略思考(国外英语资料).doc
- “泰山”酒品牌能否五岳独尊(国外英语资料).doc
- “渠道”三变(国外英语资料).doc
- “未来,为我而来!”套用这句广告语,这也许是对栖城团队的完美诠释(国外英语资料).doc
- “人力本钱”的哲学审阅201795(国外英语资料).doc
- “特殊群体”扩大是种特殊警示(国外英语资料).doc
原创力文档

文档评论(0)