from my SP output, the stud id ,name column cannot be repeat for the same student
i written the store procedure as follows;
set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGO --exec [OH_BatchWise_Collection_Report] 'B10720' --this store procedure is used to get the batchwise fee collection report ALTER procedure [dbo].[OH_BatchWise_Collection_Report](@BatchId varchar(10))asbegin declare @SNo int,@stud_name varchar(100),@stud_id varchar(100),@CrBillNo varchar(20),@BillNo varchar(20),@Rcptno varchar(20),@Rcptdt varchar(20),@RcptAmt varchar(20),@Chqtype varchar(20) --added create table #TempTable(SNo int, Stud_ID varchar(10), Stud_Name varchar(100),Rcptno varchar(20),Rcptdt varchar(20), RcptAmt varchar(20),Chqtype varchar(20)) --added declare Batchwise cursor forselect s.stud_id, s.stud_name, cr.cr_bill_no from course_registration cr, batch_course_registration bcr, student swhere cr.stud_id = s.stud_id and bcr.cr_bill_no = cr.cr_bill_no and cr.cr_active = 'A' and bcr.bcr_batch_id = @BatchId SET @SNo = 0open Batchwisefetch next from Batchwise into @stud_id, @stud_name, @CrBillNoWhile @@Fetch_status = 0begin--Getting the receipt detailsselect @BillNo = bill_no from bill_file2 where cr_bill_no = @CrBillNo and bill_active = 'A'SET @SNo = @SNo + 1 declare Batchwise_cur cursor for select r.rcpt_no, convert(char(12),r.rcpt_dt,106) as Rcptdt, r.rcpt_amt from receipt_file2 r where r.bill_no = @BillNo open Batchwise_curfetch next from Batchwise_cur into @Rcptno, @Rcptdt, @RcptAmtwhile @@Fetch_status = 0beginset @Chqtype = ''select @Chqtype =chq_type from cheque_file2 where rcpt_no= @Rcptno insert into #TempTable values(@SNo, @stud_id, @stud_name, @Rcptno,@Rcptdt,@RcptAmt,@Chqtype) fetch next from Batchwise_cur into @Rcptno, @Rcptdt, @RcptAmtend close Batchwise_curdeallocate Batchwise_cur fetch next from Batchwise into @stud_id, @stud_name, @CrBillNoend close Batchwisedeallocate Batchwise select * from #TempTable end Output as follows; sno stud_id Name rcptno rcpt date rcpt amt chq type1 58172 RALPH BENNET .R 1572 21 Apr 2012 100000.00 DEMAND DRAFT 1 58172 RALPH BENNET .R 1573 21 Apr 2012 59000.00 DEMAND DRAFT 2 58167 ROBIN S.R 1564 21 Apr 2012 59000.00 DEMAND DRAFT 2 58167 ROBIN S.R 1890 24 Jun 2012 100000.00 DEMAND DRAFT But i want the output as follows; how can i get the below output.
sno stud_id Name rcptno rcpt date rcpt amt chq type
1 58172 RALPH BENNET .R 1572 21 Apr 2012 100000.00 DEMAND DRAFT
1573 21 Apr 2012 59000.00 DEMAND DRAFT
2 58167 ROBIN S.R 1564 21 Apr 2012 59000.00 DEMAND DRAFT
1890 24 Jun 2012 100000.00 DEMAND DRAFT
for getting the above output, in the store procedure code what code i have to written to get the above output.
please help me.
Regards,
Narasiman P.