Question : SSRS v2005 -- conditional report

I use the procedure below behind a SSRS report -- it runs multiple times throughout the day, but it's basically just an alert, letting us know if/when positions <> 0 exist on a specific endpoint.  I'd like to deliver the report ONLY if/when positions exist.  Right now, unfortunately, the report comes at every exection, regardless.  99% of them come back blank, like this:

                   There are no XXXX positions to report at this time.

Anyone able to advise on the correct way to email the report only when there are positions to report?  My procedure is below, but I think it's more an SSRS thing, than it is a tSQL thing.

Any thoughts?
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
CREATE proc procname
as
set nocount on
/* simply such that we can report if any XXXX trades exist with a position <> 0 */
 
IF EXISTS(SELECT buys-sells AS Difference
FROM
(SELECT Symbol,SUM(quantity) AS Buys 
FROM database.dbo.viewname
WHERE side = 'B' 
AND endpoint = 'XXXX'
GROUP BY symbol) buys JOIN
(SELECT Symbol,SUM(quantity) AS Sells
FROM database.dbo.viewname
WHERE side = 'S' 
and endpoint = 'XXXX'
group by symbol) sells
ON buys.Symbol = sells.Symbol
WHERE buys <> sells)
 
BEGIN
 
SELECT buys.EndPoint,buys.Symbol,Buys,Sells,buys-sells AS Difference
FROM
(SELECT EndPoint,Symbol, SUM(quantity) AS buys 
FROM database.dbo.viewname
WHERE side = 'B'
AND endpoint  = 'XXXX'
GROUP BY endpoint,symbol) buys JOIN
(SELECT EndPoint,Symbol, SUM(quantity) AS sells
FROM database.dbo.viewname
WHERE side = 'S'
AND endpoint = 'XXXX'
GROUP BY endpoint,symbol) sells
ON buys.Symbol = sells.Symbol
WHERE buys <> sells
ORDER BY buys.Symbol
 
END
 
set nocount off
GO
Open in New Window Select All

Answer : SSRS v2005 -- conditional report

i have had a great idea.... i hope.... as you know, right now, when the subscription is created, the SQL Agent job is also created, somewhat dynamically.   i was thinking i may try to add a step to the agent job, prefacing the existing step.  possibly triggering the execution of AddEvent procedure, based on OUTPUT... maybe.  not sure yet, but i am going to try it out

any input is welcome.  otherwise, i'm going to close this thing.  i'll let you know what i come up with.
Random Solutions  
 
programming4us programming4us