存储过程CREATE PROC upGetUserName
@intGp_cq_lxin     int,
@varGp_kl2         varchar(20),
@intgongp_id       int,
@nugp_tmp_sd_dd   numeric(9,6)
 
AS
BEGIN
select count(fg) as y from (select distinct gp_tmp_zhhm as fg from chjdr_temp where Gp_cq_lxin=@intGp_cq_lxin and Gp_leixin >0 and Gp_kl like '%@varGp_kl2%'
 and g_gongp_id=@intgongp_id GROUP BY gp_tmp_zhhm having sum(gp_tmp_sd)>=@nugp_tmp_sd_dd) as j
END
GO
ASP调用'exec upGetUserName 0,'2010',19,'189.661'  set rsmi=Server.CreateObject("ADODB.Recordset") 
sql = "exec upGetUserName "&iGpcq_lxin&",'"&Gp_kl2&"',"&gongp_id&",'"&gp_tmp_sd_dd&"'"
Response.Write(sql)
rsmi.open sql,conn,3,2结果是0exec upGetUserName 0,'2010',19,'189.661'   在查询分析器里执行后结果也是0把数据带入SQL语句里结果正常/

解决方案 »

  1.   

    select count(fg) as y from 
    (
    select distinct gp_tmp_zhhm as fg 
    from chjdr_temp 
    where Gp_cq_lxin=@intGp_cq_lxin 
    and Gp_leixin >0 
    and Gp_kl like '%'+@varGp_kl2+'%'  ---修改
    and g_gongp_id=@intgongp_id 
    GROUP BY gp_tmp_zhhm 
    having sum(gp_tmp_sd)>=@nugp_tmp_sd_dd
    ) as j
      

  2.   

    select count(fg) ,统计数量。两者结果是0,没错。但你的SQL语句有问题,传入的参数是变量,你得用“+”串联。
    select count(fg) as y from (select distinct gp_tmp_zhhm as fg from chjdr_temp where Gp_cq_lxin=@intGp_cq_lxin and Gp_leixin >0 and Gp_kl like "%'+@varGp_kl2+'%"
     and g_gongp_id=@intgongp_id GROUP BY gp_tmp_zhhm having sum(gp_tmp_sd)>=@nugp_tmp_sd_dd) as j
      

  3.   

    select count(fg) as y from 
    (
      select distinct gp_tmp_zhhm as fg 
      from chjdr_temp 
      where Gp_cq_lxin=@intGp_cq_lxin and Gp_leixin >0 and Gp_kl like '%' + @varGp_kl2 + '%' --这里写错了。
      and g_gongp_id=@intgongp_id 
      GROUP BY gp_tmp_zhhm 
      having sum(gp_tmp_sd)>=@nugp_tmp_sd_dd
    ) as j
      

  4.   


    dawugui
     
    (爱新觉罗.毓华) 等 级: 
    3
    更多勋章 #4楼 得分:0回复于:2010-09-27 09:24:37SQL codeselect count(fg) as y from 
    (
      select distinct gp_tmp_zhhm as fg 
      from chjdr_temp 
      where Gp_cq_lxin=@intGp_cq_lxin and Gp_leixin >0 and Gp_kl like '%' + @varGp_kl2 + '%' --这里写错了。
      and g_gongp_id=@intgongp_id 
      GROUP BY gp_tmp_zhhm 
      having sum(gp_tmp_sd)>=@nugp_tmp_sd_dd
    ) as j