TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
768.6k
from my SPoutput, thestudid,namecolumncannot be repeat
Apr 17 2013 7:52 AM
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 ON
set QUOTED_IDENTIFIER ON
GO
--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))as
begin
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 for
select s.stud_id, s.stud_name, cr.cr_bill_no from course_registration cr, batch_course_registration bcr, student s
where 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 = 0
open Batchwise
fetch next from Batchwise into @stud_id, @stud_name, @CrBillNo
While @@Fetch_status = 0
begin
--Getting the receipt details
select @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_cur
fetch next from Batchwise_cur into @Rcptno, @Rcptdt, @RcptAmt
while @@Fetch_status = 0
begin
set @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, @RcptAmt
end
close Batchwise_cur
deallocate Batchwise_cur
fetch next from Batchwise into @stud_id, @stud_name, @CrBillNo
end
close Batchwise
deallocate Batchwise
select * from #TempTable
end
Output as follows;
sno stud_id Name rcptno rcpt date rcpt amt chq type
1 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.
Reply
Answers (
1
)
keyboard arrow keys in c sharp?
Replace text in RichTextBox