Re: try catch ok, what about finally?

Tech-Archive recommends: Fix windows errors by optimizing your registry




"JCollum" <jcollum@xxxxxxxxx> wrote in message
news:1162937887.852302.7560@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

It appears to work from here. Is this test similar to what you are trying
to do?

CREATE TABLE #test (i INT NOT NULL PRIMARY KEY);
CREATE TABLE #log (err NVARCHAR(2000) NOT NULL);

INSERT INTO #test (i)
VALUES (1);

BEGIN TRY
INSERT INTO #test (i)
VALUES (1);
END TRY
BEGIN CATCH
INSERT INTO #log (err)
VALUES (ERROR_MESSAGE());
END CATCH

SELECT * FROM #log;

DROP TABLE #test;
DROP TABLE #log;


.