SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_act_branches_cies_edit]
	@brc_branch_id INT
AS
	SET NOCOUNT ON;

	SELECT	brc_branch_id = @brc_branch_id,
			brc_company_id = ac.cie_actor_id,
			vir_item_is_selected = CONVERT(BIT, CASE WHEN abc.brc_branch_id IS NULL THEN 0 ELSE 1 END),
			ac.*
	FROM	vw_act_cies ac
		LEFT JOIN act_branches_cies abc ON		ac.cie_actor_id = abc.brc_company_id
											AND abc.brc_branch_id = @brc_branch_id
	
		
		
GO
