SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_grid_act_cies_treaties]
	@company_id as varchar(15)
AS

set nocount on

declare @id int 

if @company_id = '%'
	set @id = 0
else
	set @id = convert(int, @company_id)

select *
from vw_act_cies
where		( @id = 0 or act_actor_id = @id )
		and act_actor_id not in (	select trtc_company_id 
									from act_treaties_companies
									where trtc_actor_id = @id
								)

GO
