SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].[p_usr_users_options_add]
	@users_table type_table_code_medium readonly 
as
BEGIN
	
	SET NOCOUNT ON;

	/*
	DGE 24/05/2017
	Ajouter les options par défaut pour les utilisateurs qui n'existent pas
	*/

	insert into usr_users_options (	usro_user_code )
	select	distinct t.code_medium
	from	@users_table t
			inner join usr_users u on u.usr_user_code = t.code_medium
	where not exists (	select	1
						from	usr_users_options o 
						where	o.usro_user_code = t.code_medium )


END
GO
