IF NOT EXISTS(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='PRC_FILIAL_GLB_CRM') 
BEGIN
CREATE TABLE [dbo].[PRC_FILIAL_GLB_CRM](
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_CRM] [int] NOT NULL,
 CONSTRAINT [PK_PRC_FILIAL_GLB_CRM] PRIMARY KEY CLUSTERED 
(
	[CD_EMP] ASC,
	[CD_FILIAL] ASC,
	[CD_CRM] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY];

ALTER TABLE [dbo].[PRC_FILIAL_GLB_CRM]  WITH CHECK ADD  CONSTRAINT [FK_PRC_FILIAL_GLB_CRM_GLB_CRM] FOREIGN KEY([CD_CRM])
REFERENCES [dbo].[GLB_CRM] ([CD_CRM])

ALTER TABLE [dbo].[PRC_FILIAL_GLB_CRM] CHECK CONSTRAINT [FK_PRC_FILIAL_GLB_CRM_GLB_CRM];
END
