sql - Handle more than one returning value in stored procedure -
i have following stored procedure
alter proc spinparam ( @partycode nvarchar(50) ) begin declare @totalamount float declare @setloop int declare @setcnt int print 'party code '+@partycode; set @totalamount=(select totalamount billparticular partycode=@partycode) set @setloop=(select count(totalamount) billparticular partycode=@partycode) set @setcnt=0; while @setcnt<=@setloop begin print 'total bill amt.'+convert(nvarchar(50),@totalamount); set @setcnt=@setcnt+1; end return convert(nvarchar(50),@totalamount) end in stored procedure,
select totalamount billparticular partycode=@partycode query returns more 1 values. (i.e. there 2 totalamounts particular @partycode) how can take them in loop?
i set while loop shown in code.
this stored procedure compiled well. while executing, gave me following error:
party code 0l036 msg 512, level 16, state 1, procedure spinparam, line 11 subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. please guid me should done in existing procedure.
please tell me if making mistake anywhere.
please me.
sample output:
party code: 0l036 total bill amount:1074432000 total bill amount:2108208000 billparticular table:

edit:
declare @partycode nvarchar(50); records ( select 'total bill amount : ' + convert(nvarchar(50), totalamount) str_output billparticular partycode = @partycode ) select 'party code ' + @partycode str_output union select str_output records returning null
with records ( select 'total bill amount : ' + convert(nvarchar(50), totalamount) str_output billparticular partycode = @partycode ) select 'party code ' + @partycode str_output union select str_output records
Comments
Post a Comment