CREATE PROCEDURE [C6MartPeriodico].[Monitoraggio_Giornaliero]
AS
BEGIN 
declare @id1  as int 
select  @id1 = MAX (id)  from consuni.[ConsulenzaUnicaFL].[dbo].semaforo where nomebatch='Giornaliero'
declare @conta2 as int
set @conta2 = 0
while ( @conta2 = 0 )
begin
waitfor delay '00:00:30';
select @conta2 = flsemaforo from consuni.[ConsulenzaUnicaFL].[dbo].semaforo where id=@id1
end
END