• 成熟sql 分页存储过程(UP_General_SelectByWhere)


    View Code
     1 GO
    2 /****** Object: StoredProcedure [dbo].[UP_General_SelectByWhere] Script Date: 03/17/2011 10:49:23 ******/
    3 SET ANSI_NULLS ON
    4 GO
    5 SET QUOTED_IDENTIFIER ON
    6 GO
    7 -- =============================================
    8 -- Author: <Author,,Name>
    9 -- Create date: <Create Date,,>
    10 -- Description: <Description,,>
    11 -- =============================================
    12 ALTER PROCEDURE [dbo].[UP_General_SelectByWhere]
    13 (
    14 @strSelect NVarChar (1000),
    15 @strWhere NVarChar (4000),
    16 @strTable NVarChar (50),
    17 @strOrderfld NVarChar (100),
    18 @OrderType bit = 0
    19 )
    20 AS
    21 BEGIN
    22 DECLARE @strSQL varchar(8000) -- 主语句
    23 DECLARE @strOrder varchar(400) -- 排序类型
    24 IF(@strOrderfld!='')
    25 BEGIN
    26 if @OrderType!= 0 -- 降序(desc)
    27 BEGIN
    28 set @strOrder = ' order by ' + @strOrderfld +' desc ' --如果@OrderType不是0,就执行降序,这句很重要!
    29 END
    30 ELSE -- 升序(asc)
    31 BEGIN
    32 set @strOrder = ' order by ' + @strOrderfld +' asc '
    33 END
    34 SET @strSQL= ' select '+@strSelect+' from '+ @strTable+' where 1=1 ' + @strWhere+@strOrder
    35 END
    36 ELSE
    37 BEGIN
    38 SET @strSQL= ' select '+@strSelect+' from '+ @strTable+' where 1=1 ' + @strWhere
    39 END
    40 EXECUTE(@strSQL)
    41 END

  • 相关阅读:
    值传递和引用传递
    tomcat配置默认目录
    oracle用户和表空间
    oracle组内排序
    tomcat参数修改
    easyui格式化复选框
    关于spring mvc时间类型绑定失败解决方法
    java web汉字传参的解决办法
    Easyui中使用jquery或js动态添加元素时出现的样式失效的解决方法
    Postman接口测试(一)安装以及使用
  • 原文地址:https://www.cnblogs.com/yeminglong/p/2212921.html
Copyright © 2020-2023  润新知