When I run this stored proc, I get this error:"The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION." I'm not sure wht the rules are for using transaction...SET NOCOUNT ONDECLARE ...-- append a separator at the end of the arraySET @compNums = @compNums + @separatorSET @frequencies = @frequencies + @separatorSET @duedates = @duedates + @separatorSET @cycledates = @cycledates + @separatorwhile patindex('%' + @separator + '%' , @compNums) <> 0BEGIN select @separator_comp = patindex('%' + @separator + '%' , @compNums) select @separator_date = patindex('%' + @separator + '%' , @duedates) select @separator_freq = patindex('%' + @separator + '%' , @frequencies) select @separator_cycle = patindex('%' + @separator + '%' , @cycledates) --get the member element select @compNum = left(@compNums , @separator_comp - 1) select @duedate = left(@duedates , @separator_date - 1) select @freq = left(@frequencies , @separator_freq - 1) select @cycle = left(@cycledates , @separator_cycle - 1) SET @bookexists = NULL -- check if PDF request exists in AutoRun for company SELECT @bookexists = 1 FROM dbo.AutoRun WHERE CompNum = @compNum AND FileType = 'PDFSTMT' IF @stmt = 1 --stmt requested BEGIN IF @bookexists IS NULL --record doesn't exist in AutoRun table BEGIN IF @duedate <> '' OR @duedate = '0' BEGIN BEGIN TRANSACTION INSERT INTO dbo.AutoRun(ICN, FileType, CompNum, Frequency, DueDate) VALUES (@icn, 'PDFSTMT', @compNum, @freq, @duedate) IF @@ERROR != 0 GOTO ERROR_HANDLER Update dbo.CompNames Set AutomateStmts = 1 Where CompNum = @compNum AND InternetNumber = @icn IF @@ERROR != 0 GOTO ERROR_HANDLER IF @freq = 'CDPLUS' BEGIN --if submission (today) is past the cycle date IF (SELECT DATEDIFF(d, GETDATE(), (@cd))) <= 0 BEGIN --if today's date is less than or equal to the cycle date + duedate, insert or update record in FileAdmin table with the rundate as cycledate+duedate IF (SELECT DATEDIFF(d,GETDATE(),(@cd + CAST(@duedate as int)))) >= 0 BEGIN --if record exists in FileAdmin, update rundate IF Exists (Select 1 from dbo.Fileadmin Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1) BEGIN Update dbo.FileAdmin Set dteRunDate = @rundate Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1 IF @@ERROR != 0 GOTO ERROR_HANDLER END ELSE -- record doesn't exist in FileAdmin, do an insert BEGIN INSERT INTO dbo.FileAdmin (txtCompanyNum, txtAddOpt, dteCycleDate, dteLastUsed, blnExported, txtInternetNum, txtStatus, dteRunDate, txtFileType, blnAutomatedRequest ) VALUES (@compNum, '', @cd, GETDATE(), 0, @icn, '', @rundate , 'PDFSTMT', 1 ) IF @@ERROR != 0 GOTO ERROR_HANDLER END END END END COMMIT TRANSACTION END END ELSE --record already exists in AutoRun table BEGIN IF @duedate <> '' Or @duedate = '0' BEGIN BEGIN TRANSACTION UPDATE dbo.AutoRun SET DueDate = CAST(@duedate as int), Frequency = @freq WHERE CompNum = @compNum AND FileType = 'PDFSTMT' IF @@ERROR != 0 GOTO ERROR_HANDLER --does record already exist in FileAdmin? IF Exists (Select 1 from dbo.Fileadmin Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1) BEGIN IF @freq = 'CDPLUS' BEGIN --if today's date is less than or equal to the cycle date + duedate, update record in FileAdmin table with the rundate as cycledate+duedate IF (SELECT DATEDIFF(d,GETDATE(),(@cd + CAST(@duedate as int)))) >= 0 BEGIN Update dbo.FileAdmin Set dteRunDate = @rundate Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1 IF @@ERROR != 0 GOTO ERROR_HANDLER END END ELSE --DOM BEGIN Delete From dbo.FileAdmin Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1 IF @@ERROR != 0 GOTO ERROR_HANDLER END END COMMIT TRANSACTION END ELSE --due date is empty BEGIN BEGIN TRANSACTION DELETE FROM dbo.AutoRun WHERE CompNum = @compNum AND FileType = 'PDFSTMT' IF @@ERROR != 0 GOTO ERROR_HANDLER UPDATE dbo.CompNames Set AutomateStmts = 0 Where CompNum = @compNum AND InternetNumber = @icn IF @@ERROR != 0 GOTO ERROR_HANDLER DELETE From dbo.FileAdmin Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1 IF @@ERROR <> 0 GOTO ERROR_HANDLER COMMIT TRANSACTION END END END ELSE --stmt not requested BEGIN IF @bookexists = 1 BEGIN BEGIN TRANSACTION DELETE FROM dbo.AutoRun WHERE CompNum = @compNum AND FileType = 'PDFSTMT' IF @@ERROR != 0 GOTO ERROR_HANDLER UPDATE dbo.CompNames Set AutomateStmts = 0 Where CompNum = @compNum AND InternetNumber = @icn IF @@ERROR != 0 GOTO ERROR_HANDLER DELETE From dbo.FileAdmin Where txtCompanyNum = @compNum And blnExported = 0 And txtFileType = 'PDFSTMT' And blnAutomatedRequest = 1 IF @@ERROR != 0 GOTO ERROR_HANDLER COMMIT TRANSACTION END END --remove member element from the array select @compNums = stuff(@compNums, 1, @separator_comp, '') select @duedates = stuff(@duedates, 1, @separator_date, '') select @frequencies = stuff(@frequencies, 1, @separator_freq, '') select @cycledates = stuff(@cycledates, 1, @separator_cycle, '') ENDERROR_HANDLER: ROLLBACK TRANSACTION SET NOCOUNT OFF SET NOCOUNT OFFGO