Link to home
Start Free TrialLog in
Avatar of johnnyaction
johnnyaction

asked on

SQL Syntax problem

I got a quick question that it not making sense to me ...

I run this
DECLARE @NextMailingDate as varchar(200)
DECLARE @MailingDate as datetime      

SELECT @MailingDate = MIN(MailingDate) --AS NextMailDate
      from tblMSDesignMailings WHERE (JobRFID IN(Select JobRFID From #tmpTable2)) AND (MailingDate > GetDate()) ;
      SET @NextMailingDate = 'Next mailing scheduled for: '       
 SELECT @NextMailingDate
RETURNS =  'Next mailing scheduled for: '
and the results are as you would think but when I try to concatenate a date to it, if the date is NULL the whole string goes away for some reason. For instance, if I run this it returns NULL

DECLARE @NextMailingDate as varchar(200)
DECLARE @MailingDate as datetime      

SELECT @MailingDate = MIN(MailingDate) --AS NextMailDate
from tblMSDesignMailings WHERE (JobRFID IN(Select JobRFID From #tmpTable2)) AND (MailingDate > GetDate()) ;
SET @NextMailingDate = 'Next mailing scheduled for: '
SET @NextMailingDate = @NextMailingDate + cast(@MailingDate as varchar(10))+ '<br /><br />' This line seems to ruin it for some reason and I cant figure out why???

 SELECT @NextMailingDate
Returns = NULL

Thanks for any help
ASKER CERTIFIED SOLUTION
Avatar of MohammedU
MohammedU
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of johnnyaction
johnnyaction

ASKER

I was just abuot to reply to my own post that I used the ISNULL function...But you answered it so the points are yours...Thanks for the help!
thanks