Hi,
I have a scenario.
DECLARE @INPUTFILENAME VARCHAR(100)
DECLARE @MAXLOAD_DT DATE
DECLARE @FILEDATENAME DATE
SET @INPUTFILENAME ='FileName-20131128' -----Filename
SELECT @MAXLOAD_DT='20130628'
SELECT @FILEDATENAME=convert(date,substring(@INPUTFILENAME,10,8),104)
SELECT CASE WHEN @MAXload_DT <= @FILEDATENAME THEN 0 ELSE 1 END
This query gives output as 0.
Incase if the filename comes with error , say example, 'filename -20121128', then this will throw error.
But the requirement is -if the file name is wrong, then NULL should be return, without failiing the query.
Please help!
thanks in advance!