各位大侠!请不惜赐教!菜鸟感激不尽!
在调用存储过程时,即使直接给存储过程的输入参数赋值,输出也是空值!
而直接在sqlserver里的查询下,单独运行其中的查询语句时,能得到正确结果!附1:存储过程:CREATE PROCEDURE  CountTotal  ALTER PROCEDURE [dbo].[BBB] 
@cid int  
AS
BEGIN
declare @cou int
SET NOCOUNT ON;
select * from [v_price_type_w] where anchor=1 and cityid=@cid and substring(leib,2,2)= '_2' order by oid
select * from [v_price_type_w] where anchor=1 and cityid=@cid and leib like '2[_]1[_]%' order by oid
select * from [v_price_type_w] where anchor=1 and cityid=@cid and leib like '2[_]3[_]%' order by oid
select * from [v_price_type_w] where anchor=1 and cityid=@cid and leib like '2[_]4[_]%' order by oid
end

解决方案 »

  1.   

    在调用存储过程时,即使直接给存储过程的输入参数赋值,输出也是空值!
    而直接在sqlserver里的查询下,单独运行其中的查询语句时,能得到正确结果!--真的吗,从代码看应该不会有这种情况
      

  2.   


    ALTER PROCEDURE [dbo].[BBB] 
        @cid int=null
    AS
    BEGIN
        declare @cou int
        SET NOCOUNT ON;
        select * from [v_price_type_w] where anchor=1 and cityid=isnull(@cid,cityid) and substring(leib,2,2)= '_2' order by oid
        select * from [v_price_type_w] where anchor=1 and cityid=isnull(@cid,cityid) and leib like '2[_]1[_]%' order by oid
        select * from [v_price_type_w] where anchor=1 and cityid=isnull(@cid,cityid) and leib like '2[_]3[_]%' order by oid
        select * from [v_price_type_w] where anchor=1 and cityid=isnull(@cid,cityid) and leib like '2[_]4[_]%' order by oid
    end
    go
      

  3.   

    我直接在sqlserver里的查询分析器下,单独运行其中的查询语句时,能得到正确结果!
    比如:select * from [v_price_type_w] where anchor=1 and cityid=464 and substring(leib,2,2)= '_2' order by oid
    或者
        select * from [v_price_type_w] where anchor=1 and cityid=464 and leib like '2[_]1[_]%' order by oid
    在SQL server 2008 中,“执行存储过程”,输入值:464,返回空值
    请高工 帮忙分析一下原因