SQL - is not null syntax help - SQL Server 2005
Posted on 2011-03-04
I have the below snippet of code that is causing me troubles.
declare @HGA1C varchar(30)
set @HGA1C= ''
if (@HGA1C is not null or @HGA1C <> '')
set @HGA1C = CONVERT(VARCHAR(10), convert(datetime,@HGA1C, 101),101 )
When I run the above code it returns '01/01/1900'
However, I would like it to simply return a blank segment. Is there any way to code around this? My problem is that most of the time this @HGA1C variable HAS a value, but sometimes it is blank - and my if statement above almost seems to be ignored.