Hi all,
I have to run a list of stored procedures. One of them returns error 'The server principal ... is not able to access the database ... under the current security context'. I'm ok with it as I don't have needed access rights yet. What is not ok is that I'd like to handle it using try ... catch block and put the error into the log instead of displaying it in 'Messages' SSMS window. Tried try ... catch like below:
BEGIN TRY BEGIN TRAN EXEC [EXAMPLEDB].[EXAMPLESCHEMA].[EXAMPLESTOREDPROCEDURE] @EXAMPLEINPUTPARAMETER COMMIT TRAN END TRY BEGIN CATCH ROLLBACK TRAN END CATCH
Ok, I will need to put logging stuff into BEGIN CATCH ... END CATCH block as a next step. For now, I would expect that EXAMPLESTOREDPROCEDURE silently fails, but it does display error.
Please advise.