set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id='+RTRIM(@cid)+' AND Published=1'

解决方案 »

  1.   

    set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id='''+@cid+''' AND Published=1' 
      

  2.   

    --沒發現問題
    USE [hotcewebsite] 
    GO 
    /****** 对象:  StoredProcedure [dbo].[articleList_proc]    脚本日期: 01/08/2009 09:24:33 ******/ 
    SET ANSI_NULLS ON 
    GO 
    SET QUOTED_IDENTIFIER ON 
    GO 
    -- =========================================== 
    ALTER PROCEDURE [dbo].[articleList_proc] 
    /* 
    后台ARTICLELIST文件所用的存储过程 
    */ 
    @cid int, ---文章分类号 
    @sj varchar(20),---标题 
    @keyword varchar(50), ---关键字 
    @AddUser_id int, ---写入者号 
    @IsPass int, ---是否通过 
    @startTime varchar(50),---开始时间 
    @endTime varchar(50)---结束时间 
    AS 
    declare @firstStr varchar(200) 
    set @firstStr = 'select top 100 * from Article ' 
    declare @condition varchar(1000) 
    set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id=@cid AND Published=1' 
    if (@sj <> null) 
    begin 
    set @condition = @condition+' AND Subject LIKE @sj ' 
    end if(@keyword <> null) 
    begin 
    set @condition = @condition+' AND [Keyword] LIKE @keyword ' 
    end if @AddUser_id>0 
    begin 
    set @condition = @condition+' AND AddUser_id=@AddUser_id ' 
    end if(@IsPass>=0) 
    begin 
    set @condition = @condition+' AND IsPass=@IsPass' 
    end if(@startTime <>null and @endTime <>null) 
    begin 
    set @condition = @condition+' AND (AddTime Between @startTime AND @endTime)' 
    end 
    declare @lastStr varchar(200) 
    set @lastStr = ' order by [id] desc' 
    set @condition = @firstStr+@condition+@lastStr 
    exec (@condition) 
    -- ============================================= 
    -- Example to execute the stored procedure 
    -- ============================================= 
    execute [dbo].[articleList_proc] '50081','诺基亚','诺基亚','50','1','2008-12-8 11:43:40','2008-12-10 17:49:00' 
    Go 
      

  3.   

    set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id='+cast(@cid as nvarchar(20))+' AND Published=1'