I've been researching for past two days and hitting my head against wall, but I can't figure this out.
I am trying to insert error message into a table along with the data that goes with it. So here how my statement looks:
--INSERT INTO InsertStatementErrors
SELECT f.* , 0 AS [ErrorResolvedYesNo],
ERROR_NUMBER() ErrorNBR ,
ERROR_SEVERITY() Severity ,
ERROR_LINE() ErrorLine ,
GETDATE() AS [TimeAndDateAdded]
FROM froi_import f
WHERE Insured_ID = @Insured_ID and record_id = @record_id
When I comment out the INSERT INTO, it displayed the error on the screen. But when I enable the INSERT INTO, it doesn't insert the data into the table neither it gives me any error message. I can't figure out what I am doing wrong.