﻿IF OBJECT_ID('dev.uspRegisterSPFN') IS NOT NULL BEGIN
  DROP PROCEDURE dev.uspRegisterSPFN
END;
GO
CREATE PROCEDURE [dev].[uspRegisterSPFN]
  @spFnName nvarchar(255),
  @IsProcedure bit
AS
BEGIN
  SET NOCOUNT ON;

  UPDATE VersionInfoSPFN SET
    RegisteredAt = GETDATE()
  WHERE Name = @spFnName AND IsSchemaUpdated = 0
  IF @@ROWCOUNT = 0 BEGIN
    INSERT INTO VersionInfoSPFN (Name, IsProcedure, IsSchemaUpdated, RegisteredAt) VALUES
      (@spFnName, @IsProcedure, 0, GETDATE());
  END
END
GO