﻿IF OBJECT_ID('dbo.fnGuidValidation') IS NOT NULL BEGIN
  DROP FUNCTION dbo.fnGuidValidation
END
GO

CREATE FUNCTION dbo.fnGuidValidation (
     @loginName nvarchar(36)
    ,@intezmenyId int
) RETURNS int
BEGIN
  RETURN (
    SELECT COUNT(DISTINCT C_GUID)
    FROM [dbo].[T_FELHASZNALOBELEPES]
    WHERE C_BEJELENTKEZESINEV = @loginName
      AND C_INTEZMENYID = @intezmenyId
      AND TOROLT='F'
  )
END;
GO