alter procedure pro_modify_shoukuan
@client_id int,@id int output
as
select @id=max(id) from [contract]
where client_id=@client_id
declare @id int
pro_modify_shoukuan 0045,@id请问下我这句最后的执行为什么老是说我有错误
错误如下
消息102,级别15,状态1,第3 行
'pro_modify_shoukuan' 附近有语法错误。

解决方案 »

  1.   

    加上EXECEXEC pro_modify_shoukuan 0045,@id 这样就可以了~
      

  2.   

    USE AdventureWorks;
    GO
    IF OBJECT_ID ( 'Production.usp_GetList', 'P' ) IS NOT NULL 
        DROP PROCEDURE Production.usp_GetList;
    GO
    CREATE PROCEDURE Production.usp_GetList @product varchar(40) 
        , @maxprice money 
        , @compareprice money OUTPUT
        , @listprice money OUT
    AS
        SELECT p.name AS Product, p.ListPrice AS 'List Price'
        FROM Production.Product p
        JOIN Production.ProductSubcategory s 
          ON p.ProductSubcategoryID = s.ProductSubcategoryID
        WHERE s.name LIKE @product AND p.ListPrice < @maxprice;
    -- Populate the output variable @listprice.
    SET @listprice = (SELECT MAX(p.ListPrice)
            FROM Production.Product p
            JOIN  Production.ProductSubcategory s 
              ON p.ProductSubcategoryID = s.ProductSubcategoryID
            WHERE s.name LIKE @product AND p.ListPrice < @maxprice);
    -- Populate the output variable @compareprice.
    SET @compareprice = @maxprice;
    GO
    DECLARE @compareprice money, @cost money 
    EXECUTE Production.usp_GetList '%Bikes%', 700, 
        @compareprice OUT, 
        @cost OUTPUT
    IF @cost <= @compareprice 
    BEGIN
        PRINT 'These products can be purchased for less than 
        $'+RTRIM(CAST(@compareprice AS varchar(20)))+'.'
    END
    ELSE
        PRINT 'The prices for all products in this category exceed 
        $'+ RTRIM(CAST(@compareprice AS varchar(20)))+'.'
      

  3.   

    可以我的@id不是已经声明为output了嘛?
    也declare过了
    为什么还说我需要声明标量变量呢>?
      

  4.   

     用sp_executesql 输出参数 
    declare @num int, 
            @sqls nvarchar(4000) 
    set @sqls='select count(*) from tableName' 
    exec(@sqls) 
    --如何将exec执行结果放入变量中? declare @num int, 
                   @sqls nvarchar(4000) 
    set @sqls='select @a=count(*) from tableName ' 
    exec sp_executesql @sqls,N'@a int output',@num output 
    select @num 
      

  5.   


    参考上面的代码..加上OUT参数
      

  6.   

    alter procedure pro_modify_shoukuan
    @client_id int,@id int output
    as
    select @id=max(id) from [contract]
    where client_id=@client_id
    GOdeclare @id int
    EXEC pro_modify_shoukuan 0045,@id 
      

  7.   

    alter procedure pro_modify_shoukuan
    @client_id int,@id int output
    as
    select @id=max(id) from [contract]
    where client_id=@client_id
    GOdeclare @id int
    EXEC pro_modify_shoukuan 0045,@id OUT
    select @id