﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE procedure [dbo].[InsertStopIntoLogFromDtsxImmobiliare]
	-- Add the parameters for the stored procedure here
	@Nome as varchar(100)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
    UPDATE
		dbo.LOG_ESECUZIONE_PERIODICO_IMMOBILIARE
	SET
		Fine = GETDATE()
	WHERE
		Nome = @Nome AND
		Inizio = (
			SELECT
				MAX(Inizio)
			FROM
				LOG_ESECUZIONE_PERIODICO_IMMOBILIARE
			WHERE
				Nome = @Nome
		)
END