CREATE PROCEDURE [dbo].[rank] @count int,@channel int output 
AS
BEGIN
    declare @s varchar(8000)
    set @s =   'select top '+rtrim(@count)+' id,title from info where '
             + ' channel='+rtrim(@channel)+' and isdel=0 and month(newsdate)=month(getdate()) '
             + ' order by click desc' 
    exec(@s)
END
GO

解决方案 »

  1.   

    CREATE PROCEDURE [dbo].[rank] @count int,@channel int output 
    AS
    BEGIN
        declare @s varchar(8000)
        set @s = 'select top '+rtrim(convert(varchar,@count))+' id,title from info where '
                 + ' channel='+rtrim(convert(varchar,@channel))+' and isdel=0 and month(newsdate)=month(getdate()) '
                 + ' order by click desc' 
        exec(@s)
    END
    GO