笔记147 Get存储过程
1 --的Get存储过程
2 USE [GPOSDB]
3 GO
4 /****** 对象: StoredProcedure [dbo].[CT_Append_Get] 脚本日期: 02/05/2012 21:50:40 ******/
5 SET ANSI_NULLS ON
6 GO
7 SET QUOTED_IDENTIFIER ON
8 GO
9 -----------------------------------------------------------------
10 -- Name: CT_Append Store Procedure
11 -- Author:
12 -- DateTime: 2011-07-22
13 -- Description: Data TableCT_Append , Get List
14 -----------------------------------------------------------------
15 /*
16 @PageIndex
17 @TotalRecords
18 */
19 ALTER PROCEDURE [dbo].[CT_Append_Get]
20 (
21 @PageIndex int,
22 @TotalRecords int
23 )
24 AS
25 BEGIN
26 DECLARE @Page int
27 DECLARE @PageLowerBound int
28 DECLARE @PageUpperBound int
29 DECLARE @RowsToReturn int
30
31 SET @Page = (@PageIndex - 1)
32
33 -- First set the rowcount
34 SET @RowsToReturn = @TotalRecords * (@Page + 1)
35 SET ROWCOUNT @RowsToReturn
36
37 -- Set the page bounds
38 SET @PageLowerBound = @TotalRecords * @Page
39 SET @PageUpperBound = @PageLowerBound + @TotalRecords + 1
40
41 -- Create a temp table to store the select results
42 CREATE TABLE #PageIndex
43 (
44 IndexId int IDENTITY (1, 1) NOT NULL,
45 VC_A_SNNO int
46 )
47
48 INSERT INTO #PageIndex (VC_A_SNNO)
49 SELECT
50 [VC_A_SNNO]
51 FROM
52 [CT_Append]
53
54
55 SELECT
56 c.VC_A_SNNO,
57 [VC_A_AppendType] ,
58 [VC_A_CardNO] ,
59 [I_A_CardType] ,
60 [I_A_PointToOil] ,
61 [VC_TicketType] ,
62 [VC_TicketNO] ,
63 [DE_A_BAmount] ,
64 [DE_A_AppendAmount] ,
65 [DE_A_AAmount] ,
66 [D_A_AppendDateTime] ,
67 [VC_A_Remark] ,
68 [VC_A_OperatorNO]
69 FROM [CT_Append] c , #PageIndex PageIndex
70 WHERE
71 c.VC_A_SNNO = PageIndex.VC_A_SNNO AND
72 PageIndex.IndexID > @PageLowerBound AND
73 PageIndex.IndexID < @PageUpperBound
74
75 SELECT COUNT(VC_A_SNNO) AS TotalRecords FROM [CT_Append]
76 END