Hi Team,
I've issue with catch exception and printing it in the log file which I specified. All my print statements are going into that file except the one which are in the catch block.
I'm calling a procedure in Jobs.
SET @sql = '
BULK INSERT ' + DB_NAME() + '..' + @table_name + '
FROM ''' +@currentInputFile + '''
WITH (
FIELDTERMINATOR = ''' + @Delimiter + ''',
KEEPIDENTITY,
DATAFILETYPE = ''char'',
TABLOCK,
MAXERRORS =20,
ROWTERMINATOR=''' + @RowTerminator +''')'
begin try
EXEC (@sql)
end try
begin catch
DECLARE @ErrorMessage NVARCHAR(4000)
SELECT @ErrorMessage = ERROR_MESSAGE()
print ErrorMessage
end catch
I'm calling this procedure in a job. In Job I gave Output file path where all my pront statement will log in to that file. But my error message in catch in not getting printed.
Please, help me how to catch exception into file. Its very urgent. Please help
Thanks in advance...