Untitled

mail@pastecode.io avatar
unknown
sql
a year ago
869 B
1
Indexable
Never
USE [PMP_admin]
GO
/****** Object:  StoredProcedure [dbo].[sp_PlaybackTransaction]    Script Date: 7/7/2023 1:37:47 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_PlaybackTransaction]
AS
DECLARE @Sql NVARCHAR(MAX);
DECLARE Cur CURSOR LOCAL FAST_FORWARD FOR 
SELECT  FileName
FROM PMP_admin.dbo.Logging  
where Status = 'NEW' order by FileName asc

OPEN Cur

  FETCH NEXT FROM Cur INTO @Sql 

WHILE (@@FETCH_STATUS = 0)
BEGIN TRY
BEGIN
     Exec sp_executesql @Sql
     FETCH NEXT FROM Cur INTO @Sql;
	 Update PMP_admin.dbo.Logging set status = 'Completed' where Status = 'NEW'; 
END
IF(@Sql <> 0)
BEGIN
Update PMP_admin.dbo.Logging set status = 'Failed' where Status = 'Completed';
PRINT @Sql
END
CLOSE Cur
DEALLOCATE Cur;
END TRY
BEGIN CATCH
SELECT ERROR_NUMBER(), ERROR_MESSAGE();
END CATCH