select @jine1= sum(金额) from 贡献度..手续费收入表
  where 卡号 = @kahao and 日期 like @like group by 卡号)

解决方案 »

  1.   

    select @jine1= sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like group by 卡号
      

  2.   

    CREATE PROCEDURE dbo.bb1
    @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)
    AS
    declare @jine1 decimal(18,2)
    declare @jine2 decimal(18,2)
    declare @jine3 decimal(18,2)
    declare @jine4 decimal(18,2)set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)
    set @jine2= (select 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6)
    set @jine3= (select sum(金额) from 贡献度..POS消费表
      where 卡号 = @kahao and 日期 like @like)
    set @jine4= (select sum(金额) from 贡献度..透支罚息表
      where 卡号 = @kahao and 日期 like @like)
    insert 贡献度..月报 (日期,卡号,手续费金额,存款月均金额,POS消费金额,贷款罚息金额)
    values (@riqi6,@kahao,isnull(@jine1,0),isnull(@jine2,0),isnull(@jine3,0),isnull(@jine4,0))
    GO
      

  3.   

    CREATE PROCEDURE dbo.bb1
    @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)
    AS
    begin
    declare @jine1 decimal(18,2)
    declare @jine2 decimal(18,2)
    declare @jine3 decimal(18,2)
    declare @jine4 decimal(18,2)select @jine1= sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like
    select @jine2= 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6
    select @jine3= sum(金额) from 贡献度..POS消费表
      where 卡号 = @kahao and 日期 like @like
    select @jine4= sum(金额) from 贡献度..透支罚息表
      where 卡号 = @kahao and 日期 like @like
    insert 贡献度..月报 (日期,卡号,手续费金额,存款月均金额,POS消费金额,贷款罚息金额)
    values (@riqi6,@kahao,isnull(@jine1,0),isnull(@jine2,0),isnull(@jine3,0),isnull(@jine4,0))
    end
    GO
      

  4.   

    也不行
    现在set @jine1= 数值 可以插入(select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like group by 卡号)
    也有数值
    但是
    set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)
    就没有数值
      

  5.   

    set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)
    就没有数值语法错误!!!!
    应该是
    select @jine1= sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like这样给变量赋值!执行我上面的存储过程看!
      

  6.   

    你那句我也试过了,也不行.我也奇怪了,单独赋值没问题,单独检查SELECT语句也没问题,返回的是750.00,可是就是不能将值赋给@JINE1.怪事啊!!!!!
      

  7.   

    加打印看看到底什么问题CREATE PROCEDURE dbo.bb1
    @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)
    AS
    begin
    declare @jine1 decimal(18,2)
    declare @jine2 decimal(18,2)
    declare @jine3 decimal(18,2)
    declare @jine4 decimal(18,2)select @jine1= sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like
    print @jine1
    select @jine2= 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6
    print @jine2
    select @jine3= sum(金额) from 贡献度..POS消费表
      where 卡号 = @kahao and 日期 like @like
    print @jine3
    select @jine4= sum(金额) from 贡献度..透支罚息表
      where 卡号 = @kahao and 日期 like @like
    print @jine4
    insert 贡献度..月报 (日期,卡号,手续费金额,存款月均金额,POS消费金额,贷款罚息金额)
    values (@riqi6,@kahao,isnull(@jine1,0),isnull(@jine2,0),isnull(@jine3,0),isnull(@jine4,0))
    end
    GO
      

  8.   

    select @jine2= 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6
    这句有些问题datetime
    数据最好不用= 
      

  9.   

    无心呀!!哎!你在sql里试过吗??
    楼主有报错吗??
      

  10.   

    select @jine1= sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like
    我改成
    select @jine1= 250.00 from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like
    结果是没有赋值改成set @jine1=250.00
    则有插入数值所以print @jine1肯定是NULL
      

  11.   

    日期 like @like
    有问题!条件不成立!!!去掉和日期相关的东东试试
      

  12.   

    楼主试试:
    declare  @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)declare @jine1 decimal(18,2)
    declare @jine2 decimal(18,2)
    declare @jine3 decimal(18,2)
    declare @jine4 decimal(18,2)set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)select @jine1set @jine2= (select 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6)
    select @jine2
    set @jine3= (select sum(金额) from 贡献度..POS消费表
      where 卡号 = @kahao and 日期 like @like)
    select @jine3
    set @jine4= (select sum(金额) from 贡献度..透支罚息表
      where 卡号 = @kahao and 日期 like @like)
    select @jine4
      

  13.   

    SORRY!!!在查询分析器中,
    declare @jine1 decimal(18,2)
    select @jine1=sum(金额) from 贡献度..手续费收入表
      where 卡号 = '1234123412341234' and 日期 like '200212__'
    print @jine1
    有返回值200.00declare @jine1 decimal(18,2)
    select @jine1=金额/30 from 贡献度..日存款余额表
      where 卡号 = '1234123412341234' and 日期 = '200212'
    print @jine1
    有返回值300.00declare @jine1 decimal(18,2)
    set @jine1=(select sum(金额) from 贡献度..手续费收入表
      where 卡号 = '1234123412341234' and 日期 like '200212__')
    print @jine1
    也有返回值200.00兄弟们,为什么到了存储过程里就不对了?
      

  14.   

    你的过程里
    CREATE PROCEDURE dbo.bb1
    @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)
    AS
    还是:
      

  15.   

    CREATE PROCEDURE dbo.bb1
    @riqi6 char(6),
    @day int,
    @kahao char(19),
    @like char(8)
    AS
      

  16.   

    to 无心我是说:
    set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)
    就没有数值语法错误!!!!你试过吗??????????????
      

  17.   

    楼主你过程头是用varchar还是char
    在调用的时候的代码也贴出来!!
      

  18.   

    估计是空值影响!!declare  @riqi6 varchar(6),
    @day int,
    @kahao varchar(19),
    @like varchar(8)declare @jine1 decimal(18,2)
    declare @jine2 decimal(18,2)
    declare @jine3 decimal(18,2)
    declare @jine4 decimal(18,2)
    -------------------------------
    set @like=ltrim(rtrim(@like))
    -------------------------------
    set @jine1= (select  sum(金额) from 贡献度..手续费收入表
      where 卡号 = @kahao and 日期 like @like)select @jine1set @jine2= (select 金额/@day from 贡献度..日存款余额表
      where 卡号 = @kahao and 日期 = @riqi6)
    select @jine2
    set @jine3= (select sum(金额) from 贡献度..POS消费表
      where 卡号 = @kahao and 日期 like @like)
    select @jine3
    set @jine4= (select sum(金额) from 贡献度..透支罚息表
      where 卡号 = @kahao and 日期 like @like)
    select @jine4
      

  19.   

    OK了,没有问题了:)谢谢两位,是我传递参数的时候文本框里的日期没有调整,所以找不到匹配的数据.多谢 大力 的提醒,呵呵.我给你们每人四十分吧:)
    有愿意告诉我QQ的我加为好友,呵呵