SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
DROP PROCEDURE IF EXISTS uspUpdateHatarozatstatuszByHibasNebuloAdat
GO

CREATE PROCEDURE uspUpdateHatarozatstatuszByHibasNebuloAdat
 @pTanevid int
AS
BEGIN
 UPDATE T_NEBULO SET
    C_HATAROZATSTATUSZ = 8
   ,C_HATAROZATDATUMA = IIF(C_HATAROZATSTATUSZ = 8, C_HATAROZATDATUMA, GETDATE())
 WHERE (C_TKIRANYITOSZAM2 IS NULL
    OR C_TKHELYSEGNEV2 IS NULL
    OR C_TKKOZTERULETNEV2 IS NULL
    OR C_TKHAZSZAM2 IS NULL
    OR C_TKKOZTERULETJELLEGE2 IS NULL)
   AND C_KEPVISELO2CIMEAZONOS = 'F'
   AND TOROLT = 'F' AND C_TANEVID = @pTanevId
 SELECT @@ROWCOUNT AS cnt
END
GO