I'm investigating a poorly performing procedure that I have never seen before. The procedure sets the transaction isolation level, and I suspect it might be doing so incorrectly, but I can't be sure. I'm pasting a bastardized version of the proc below, with all the names changed and the SQL mucked up enough to get through the corporate web filters.The transaction isolation level is set, but there is no explicit transaction. Am I right that there are two implicit transactions in this procedure and each of them uses snapshot isolation? SET NOCOUNT ON; SET TRANSACTION ISOLATION LEVEL SNAPSHOT; DECLARE @l_some_type varchar(20), @some_type_code varchar(3), @error int, @error_msg varchar(50); SELECT @l_some_type = @some_type; SELECT @some_type_code = some_type_code FROM dbo.some_type WHERE some_type_description = @l_some_type; IF @@ROWCOUNT = 0 BEGIN SELECTx @error = -1, @error_msg = 'Invalid some type'; GOTO Done; END; SELECTx avalue, anothervalue FROM dbo.some_table WHERE some_type_code = @some_type_code; SET @error = @@ERROR;Done: IF @error_msg > '' RAISERROR(@error_msg, 16, 1); RETURN @error;
↧