﻿DROP PROCEDURE IF EXISTS [dbo].[sp_SetBeiratkozasVeglegesites]
GO

CREATE PROCEDURE [dbo].[sp_SetBeiratkozasVeglegesites]
   @pIsVeglegesites    BIT 
  ,@pUserId        INT
AS
BEGIN

  SET NOCOUNT ON;  

  DECLARE @currentDateTime DATETIME 
  SET @currentDateTime = (SELECT GETDATE())

  IF (@pIsVeglegesites = 1)
    BEGIN
      UPDATE 
        [T_INTEZMENYADATSZOLGALTATAS] 
      SET 
         C_VEGLEGESBEIRATKOZAS =      'T'

        ,SERIAL =              SERIAL + 1
        ,LASTCHANGED =            @currentDateTime
        ,MODIFIER =              @pUserId;
    END
  ELSE
    BEGIN
      UPDATE 
        [T_INTEZMENYADATSZOLGALTATAS] 
      SET 
         C_VEGLEGESBEIRATKOZAS =      'F'

        ,SERIAL =              SERIAL + 1
        ,LASTCHANGED =            @currentDateTime
        ,MODIFIER =              @pUserId;
    END

END
GO
