From time to time, I want to run a stored procedure to get a rough estimate of how many records in two or three different tables satisfy some criteria. If during this estimate new records are added, deleted or updated, there is not really a problem (I just want a rough estimate). That being, I can afford for this process using SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
. However, I have two questions about this:
1) Since I am only using SELECT COUNT(*)
instructions, do I really need to wrap these statement in a BEGIN/COMMIT TRANSACTION
block?
2) Do I need to SET TRANSACTION ISOLATION LEVEL READ COMMITTED
back in the end of the stored procedure, or will this be automatically set once its execution ends?