待看

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



--[QN_FAVBOOKS_LIST] 5,'5,',''
-- =============================================
-- Author:        <shixiaokang>
-- Create date: <2010-8-20>
-- Description:    <收藏夹详情>
-- =============================================
ALTER proc [dbo].[QN_FAVBOOKS_LIST]
    @UserID int,
    @Parastr nvarchar(100) = '',
    /*1=UserID 2=name */
    @WebPara nvarchar(100) = ',15,1'
as
    set nocount on
    declare @uid INT
    declare @outstr varchar(100)
    declare @sortstr varchar(100)
    declare @uname varchar(100)
    declare @pagenum int
    declare @pageno int
    
    --  条件初判
    if @UserID is NULL
    begin
        select -1 ,''
        return
    END
    
    exec v6_PopFirstWord @Parastr output, @outstr output  
     if isnumeric(@outstr)=1  
      set @uid=@outstr  
     else   
      set @uid=0
      
   exec v6_PopFirstWord @Parastr output, @outstr output  
   set @uname=@outstr
   
    select identity(int, 1,1) as sortid ,
        a.*,d.GoodsName,d.License,d.Producer,d.Spec,d.CalcUnit,'~/GoodsPic/SmallPic/' + d.GoodsPic as GoodsPic,
        CAST(d.PackNum AS VARCHAR) as pack,
        --d.IS_New,d.IS_Suggest,d.IS_Promotion,
        bc.CorpName ProviderName
        into #ts
        from TBR_FAVBOOKS a
        INNER JOIN BDO_GOODS d    ON a.GoodsID = d.GoodsID
        INNER JOIN BDO_CORPORATION bc ON substring(a.Provider,1,1) = bc.CorpID
        where a.UserName = @uid AND (d.GoodsName LIKE '%'+@uname+'%' OR @uname ='')
        order by a.AddDate desc

     exec PUB_WEB_PAGEPARA @WebPara, @SortStr output, @PageNum output , @PageNo OUTPUT

    declare @count int
    select @count = count(*) from #ts
    select @count as totalcount, *  from #ts
--    
--    
--    if @pagenum is null or @count < @pagenum -- 行数少于每页行数
--        select @count as totalcount, *  from #ts
--    else
--        select @count as totalcount, * from #ts
--            where sortid > (@pageno - 1) * @pagenum and sortid <= @pageno * @pagenum
--















你可能感兴趣的:(待看)