USE [SampleDB]
GO
DROP PROCEDURE [dbo].[Sp_UpdateEmployee]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Sp_UpdateEmployee]
AS
BEGIN
DECLARE @CurrentRowCount int
BEGIN TRY
BEGIN TRANSACTION
SELECT
@CurrentRowCount = (SELECT
COUNT(*)
FROM Employee
WHERE status = 0
AND updated_on < DATEADD(dd, -90,
GETDATE()))
WHILE (@CurrentRowCount > 0)
BEGIN
UPDATE Employee
SET status = 4
WHERE updated_on < DATEADD(dd, -90, GETDATE())
END
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
END
GO
GO
DROP PROCEDURE [dbo].[Sp_UpdateEmployee]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[Sp_UpdateEmployee]
AS
BEGIN
DECLARE @CurrentRowCount int
BEGIN TRY
BEGIN TRANSACTION
SELECT
@CurrentRowCount = (SELECT
COUNT(*)
FROM Employee
WHERE status = 0
AND updated_on < DATEADD(dd, -90,
GETDATE()))
WHILE (@CurrentRowCount > 0)
BEGIN
UPDATE Employee
SET status = 4
WHERE updated_on < DATEADD(dd, -90, GETDATE())
END
COMMIT TRANSACTION
END TRY
BEGIN CATCH
ROLLBACK TRANSACTION
END CATCH
END
GO
No comments:
Post a Comment