Link to home
Create AccountLog in
Avatar of robthomas09
robthomas09

asked on

SQL - is not null syntax help - SQL Server 2005

Hello experts,
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 )

select @HGA1C

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.  

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Rajkumar Gs
Rajkumar Gs
Flag of India image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of robthomas09
robthomas09

ASKER

Thanks!
Glad I could help you
Raj