zoukankan      html  css  js  c++  java
  • 分页存储过程

    CREATE PROCEDURE  sp_fenye

    @Page int,
    @Size int

    AS

    DECLARE @Start int, @End int

    BEGIN TRANSACTION GetDataSet

    SET @Start = (((@Page - 1) * @Size) + 1)
    IF @@ERROR <> 0
     GOTO ErrorHandler

    SET @End = (@Start + @Size - 1)
    IF @@ERROR <> 0
     GOTO ErrorHandler

    CREATE TABLE #TemporaryTable
    (
     Row int IDENTITY(1,1) PRIMARY KEY,
     CustomerID nchar(5),
            OrderDate datetime,
            ShipName  nvarchar(40)
    )
    IF @@ERROR <> 0
     GOTO ErrorHandler

    INSERT INTO #TemporaryTable
    SELECT CustomerID,OrderDate,ShipName FROM Orders

    IF @@ERROR <> 0
     GOTO ErrorHandler

    SELECT CustomerID,OrderDate,ShipName
    FROM #TemporaryTable
    WHERE (Row >= @Start) AND (Row <= @End)
    IF @@ERROR <> 0
     GOTO ErrorHandler

    DROP TABLE #TemporaryTable

    COMMIT TRANSACTION GetDataSet
    RETURN 0

    ErrorHandler:
    ROLLBACK TRANSACTION GetDataSet
    RETURN @@ERROR

  • 相关阅读:
    easyui-filebox上传图片到阿里
    easyUI-filebox图片上传和预览
    抓网页__第3方库选择_01
    HttpClient示例01
    JSON01_资料
    指定library路径
    Jni_Linux_01_转
    JNI简单步骤01
    JDK_环境变量
    Redis_01
  • 原文地址:https://www.cnblogs.com/stevenxiao/p/346487.html
Copyright © 2011-2022 走看看