zoukankan      html  css  js  c++  java
  • 今儿改的

    select title from Bao_ZhaoShang where Title like '%胶囊%'


    SELECT TOP 10 bu.Companyname,bu.QQ,bz.ID,bz.UserID,bz.Title,bz.Types,bz.propic,bz.Province,bz.addtime,bz.biaozhun,bz.Hits
    from Bao_Zhaoshang bz,Bao_User bu
    where bz.UserID = bu.UserID and bz.IsShenHe = 1 and bz.title like '%胶囊%' and bz.id<(SELECT min(id) FROM (SELECT TOP 10 bz.id  FROM Bao_Zhaoshang bz  where bz.IsShenHe = 1 and bz.title like '%胶囊%' order by Addtime desc) AS TabTemp)
    order by Addtime desc


    EXEC GetDataPager 'Bao_Zhaoshang bz','bz.ID,bz.UserID','AddTime',10,2,1,1,'Title like ''%胶囊%'' and IsShenHe = 1 '

    EXEC getUserbyID 16

    CREATE PROCEDURE getUserbyID
    @UserID int
    as
    declare @strSQL nvarchar(4000) -- 主语句
    begin
         set @strSQL = 'Select UserID,QQ,CompanyName from Bao_User where UserID ='+ str(@UserID)
    end

    exec (@strSQL)
    go

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

    declare @strSQL nvarchar(4000) -- 主语句
    declare @strTmp varchar(110) -- 临时变量
    declare @strOrder varchar(400) -- 排序类型

    if @doCount != 0 --如果@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

    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

  • 相关阅读:
    清除浮动的几种方式
    css 居中问题总结
    Python 数据库Insert语句脚本生成工具(SQL Server)
    Windows安装运行Kafka
    C# 阿里云视频点播--视频转码
    C# 阿里云视频点播
    C# Assembly.LoadFile [A] 无法强制转换为 [B]
    OssFtp 用法
    C# Aspose.Words 用法
    C# 企业微信消息推送对接
  • 原文地址:https://www.cnblogs.com/pipizhu/p/1623934.html
Copyright © 2011-2022 走看看