how do you set a dynamic variable to 0 if a record does not exist in a table for a specific date range
<p>How can I set the value of a dynamic variable to 0 if no record exists for a specific date range?In the below snippet I am retrieving a transaction count of confirmed prints for a specific date range. If no records exist in the in the table how can I make the dynamic variable's value = 0?</p>

<pre><code>--ADJ-CHDC-CareHealth DiscountCard Count
            Select @SQLSG = N'Select @result = Count (tr.ConfirmedPrints) from ' + @TransactionRemote + ' tr with(nolock) left outer join location l with(nolock) on l.id = tr.LocationID
                left outer join program p with(nolock) on p.id = tr.programid 
                where ' + @PortalID + ' = l.portalID and transactiondate between'''  + convert(varchar(20),@SGStartDate,120) + ''' and ''' + convert(varchar(20),@EndDate,120) + '''' + 
                ' and l.istest=0 and tr.programID is not null and (p.programtype=''CHDC'' or p.name like ''%Adjudication Remu%'')' 
            EXEC sp_executesql @SQLSG,N'@result int OUTPUT', @result=@AdjudicatedTotalCount OUTPUT
            if (@AdjudicatedTotalCount &gt; 0)  Set @SGProgramTypeDetails = @SGProgramTypeDetails + ' ADJ-CHDC=' + convert(varchar(10),@AdjudicatedTotalCount)+ ';'
</code></pre>