IF (select COUNT(*) FROM SUBELER WHERE MEDISOFT=1) = 1
	UPDATE TMDLYATAK SET SUBEID= (SELECT SUBEID FROM SUBELER WHERE MEDISOFT= 1)
        WHERE SUBEID IS NULL
ELSE
	DELETE TMDLYATAK WHERE SUBEID IS NULL	
GO