IF NOT EXISTS (SELECT * FROM SYS.TABLES WHERE NAME = 'CTB_EXP_MOV_CENTRO_CUSTO')
begin
CREATE TABLE [dbo].[CTB_EXP_MOV_CENTRO_CUSTO](  
	[CD_LANC] [int] NOT NULL,
	[CD_CENTRO_CTB] [int] NOT NULL,
	[VLR_RAT_DESP] [money] NOT NULL  
 CONSTRAINT [PK_CTB_EXP_MOV_CENTRO_CUSTO] PRIMARY KEY CLUSTERED 
(
	[CD_LANC] ASC,
	[CD_CENTRO_CTB] 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].[CTB_EXP_MOV_CENTRO_CUSTO] ADD  CONSTRAINT [DF_CTB_EXP_MOV_CENTRO_CUSTO_VLR_RAT_DESP]  DEFAULT ((0)) FOR [VLR_RAT_DESP]

ALTER TABLE [dbo].[CTB_EXP_MOV_CENTRO_CUSTO]  WITH CHECK ADD  CONSTRAINT [FK_CTB_EXP_MOV_CENTRO_CUSTO_CTB_EXP_MOV] FOREIGN KEY([CD_LANC])
REFERENCES [dbo].[CTB_EXP_MOV] ([CD_LANC])
ON DELETE CASCADE

ALTER TABLE [dbo].[CTB_EXP_MOV_CENTRO_CUSTO] CHECK CONSTRAINT [FK_CTB_EXP_MOV_CENTRO_CUSTO_CTB_EXP_MOV]
end


