Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 HOW TO CHECK MAX DATE IN VARABILE IN SQL SERVER

Author  Topic 

rajnidas
Yak Posting Veteran

97 Posts

Posted - 2015-02-03 : 06:36:27
MY CODE IS NOT RUNNING.IT SHOULD PRINT '1900-01-01' BCOZ TEST TABLE IS BLANK.

DECLARE @CHKDT1 AS DATE
SELECT @CHKDT1 = MAX(CONVERT(DATE,COMPUTEDATE,121)) FROM test

IF (@CHKDT1 = '' OR @CHKDT1 = NULL)
BEGIN
SET @CHKDT1 = CONVERT(DATE,'1900-01-01',121)
END
print @CHKDT1


THANKS,
RAJNI

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-02-03 : 09:53:31
In SQL, "@CHKDT1 = NULL" is always FALSE.

Perhaps you mean "@CHKDT1 IS NULL"
Go to Top of Page
   

- Advertisement -