IF OBJECT_ID('EST_PROD_CPL_TRIB_ST_CRED') IS NULL
	BEGIN 
		CREATE TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED](
			[CD_CTR] [int] IDENTITY(1,1) NOT NULL,
			[CD_EMP] [int] NULL,
			[CD_FILIAL] [int] NULL,
			[CD_PROD] [int] NULL,
			[DT_MOV] [datetime] NULL,
			[QT_IT] [money] NULL,
			[QT_IT_SLD] [money] NULL,
			[VLR_BASE_ICMS] [money] NULL,
			[VLR_ICMS] [money] NULL,
			[ALIQ_ICMS] [money] NULL,
			[VLR_BASE_ICMS_ST] [money] NULL,
			[VLR_ICMS_ST] [money] NULL,
		 CONSTRAINT [PK_EST_PROD_CPL_TRIB_ST_CRED] 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_CPL_TRIB_ST_CRED]  WITH CHECK ADD  CONSTRAINT [FK_EST_PROD_CPL_TRIB_ST_CRED_EST_PROD_CPL] FOREIGN KEY([CD_EMP], [CD_FILIAL], [CD_PROD])
		REFERENCES [dbo].[EST_PROD_CPL] ([CD_EMP], [CD_FILIAL], [CD_PROD])
		ON UPDATE CASCADE


		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] CHECK CONSTRAINT [FK_EST_PROD_CPL_TRIB_ST_CRED_EST_PROD_CPL]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_QT_IT]  DEFAULT ((0)) FOR [QT_IT]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_QT_IT_SLD]  DEFAULT ((0)) FOR [QT_IT_SLD]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_VLR_BASE_ICMS]  DEFAULT ((0)) FOR [VLR_BASE_ICMS]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_VLR_ICMS]  DEFAULT ((0)) FOR [VLR_ICMS]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_ALIQ_ICMS]  DEFAULT ((0)) FOR [ALIQ_ICMS]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_VLR_BASE_ICMS_ST]  DEFAULT ((0)) FOR [VLR_BASE_ICMS_ST]

		ALTER TABLE [dbo].[EST_PROD_CPL_TRIB_ST_CRED] ADD  CONSTRAINT [DF_EST_PROD_CPL_TRIB_ST_CRED_VLR_ICMS_ST]  DEFAULT ((0)) FOR [VLR_ICMS_ST]


	END
