Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Error handling in SQL server 2012 - please help

$
0
0

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!


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>