SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_risk_situations_set_obsolete]
	@table_risks_obsolete type_risks_obsolete READONLY
as 
	set nocount on;
	
	update s
		set riss_obsolete = 1
	from ris_risks_situations s
		inner join @table_risks_obsolete o on		s.riss_risk_id = o.ris_risk_id
												and s.riss_movement_date = o.ris_last_movement_date
												and s.riss_risk_situation_id <> o.ris_last_risk_situation_id
	where s.riss_obsolete = 0

		
			

GO
