The below code throws an error when a full backup is missing.
BACKUP LOG [TESTDB] TO DISK = 'C:\DBADMIN\Backup\TESTDB_LOG.BAK'
Msg 4214, Level 16, State 1, Line 4
BACKUP LOG cannot be performed because there is no current database backup.Msg 3013, Level 16, State 1, Line 4
BACKUP LOG is terminating abnormally.
I am trying to capture the ERROR number of the statement with below code but couldn't capture the error 4214.
BEGIN TRY
BACKUP LOG [TESTDB] TO DISK = 'C:\DBADMIN\Backup\TESTDB_LOG.BAK'
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER() AS 'ERROR_NUMBER';
END CATCH
Output :
ERROR_NUMBER 3013
Please could someone help me to capture the error number 4214