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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
ASKER