May 12, 2003 at 10:48 am
I have a daily report that sends out an e-mail based on a number of print and select statements. The odd thing is that the print statements end up in the middle of the select output. Is there a way that I can force the results of the select statement to occur in the order that it appears in the stored procedure?
As an example:
Print 'line 1'
select * from customers where customer like 'a%'
Print 'line 2'
print 'line 3'
select count(*) from customers
print 'line 4'
The last print's output shows up before the results of the last select. How can I order the output? Or do I need to fetch and print each line in a cursor?
Any suggestions are welcome
Regards
Andre
May 12, 2003 at 1:07 pm
would storing the results of the select in a temp variable and printing that temp variable result in any changes...??
i.e something like :
Declare @Ctr Int
SELECT @Ctr = Count(*) from customers
Print @Ctr
Print 'Line 4'
or you could try changing all the "Print" to "Select"....i.e something like :
Select 'Line 1'
Select * from customers where customer like 'a%'
Select 'Line 2'
I think this problem might be because of the combination of Print and Select statements...if you are using QA for this report then using "Go" between the statements to break it down into batches might help...
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply