I want to lock a certain table in the event of concurrent access.
Inside a stored procedure:
- I truncate a table
- Do calculations and populate the above table
- After returning from PROCEDURE, do a select from the table
To avoid issues in event of concurrent access, I am planning to add a 'BEGIN TRANSACTION' followed by 'BEGIN TRY -END TRY' and 'BEGIN CATCH - END CATCH'. I 'COMMIT' just before 'END-TRY' and 'ROLLBACK' inside the 'CATCH'.
Will this alone resolve all concurrency issues or I need to do something more.
Many thanks, Sujit