IF OBJECT_ID('EST_PROD_TRANSF_SOLICITACAO') IS NULL
BEGIN
CREATE TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO](
	[CD_CTR] [int] IDENTITY(1,1) NOT NULL,
	[CD_EMP] [int] NOT NULL,
	[CD_FILIAL] [int] NOT NULL,
	[CD_USU] [int] NOT NULL,
	[DT_CAD] [datetime] NOT NULL,
 CONSTRAINT [PK_EST_PROD_TRANSF_SOLICITACAO] PRIMARY KEY CLUSTERED 
(
	[CD_CTR] 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].[EST_PROD_TRANSF_SOLICITACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_SOLICITACAO_CD_EMP]  DEFAULT ((0)) FOR [CD_EMP]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_SOLICITACAO_CD_FILIAL]  DEFAULT ((0)) FOR [CD_FILIAL]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_SOLICITACAO_CD_USU]  DEFAULT ((0)) FOR [CD_USU]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] ADD  CONSTRAINT [DF_EST_PROD_TRANSF_SOLICITACAO_DT_CAD]  DEFAULT (getdate()) FOR [DT_CAD]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_EST_PROD_TRANSF_SOLICITACAO_PENDENCIA] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[EST_PROD_TRANSF_SOLICITACAO_PENDENCIA] ([CD_CTR])

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] CHECK CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_EST_PROD_TRANSF_SOLICITACAO_PENDENCIA]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_EST_PROD_TRANSF_SOLICITACAO_RC_CLI] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[EST_PROD_TRANSF_SOLICITACAO_RC_CLI] ([CD_CTR])

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] CHECK CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_EST_PROD_TRANSF_SOLICITACAO_RC_CLI]

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_PRC_FILIAL] FOREIGN KEY([CD_EMP], [CD_FILIAL])
REFERENCES [dbo].[PRC_FILIAL] ([CD_EMP], [CD_FILIAL])

ALTER TABLE [dbo].[EST_PROD_TRANSF_SOLICITACAO] CHECK CONSTRAINT [FK_EST_PROD_TRANSF_SOLICITACAO_PRC_FILIAL]
end

