IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ]') AND type in (N'U'))
begin
CREATE TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ](
	[CD_CTR] [int] NOT NULL,
	[TIPO_BLQ] [int] NOT NULL,
	[DT_LIBERACAO] [datetime] NOT NULL,
	[CD_USU_LIB] [int] NOT NULL,
	[OBS_LIB] [varchar](100) NOT NULL,
 CONSTRAINT [PK_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] PRIMARY KEY CLUSTERED 
(
	[CD_CTR] ASC,
	[TIPO_BLQ] 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_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_CD_CTR]  DEFAULT ((0)) FOR [CD_CTR]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_TIPO_BLQ]  DEFAULT ((0)) FOR [TIPO_BLQ]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_CD_USU_LIB]  DEFAULT ((0)) FOR [CD_USU_LIB]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] ADD  CONSTRAINT [DF_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_OBS_LIB]  DEFAULT ('') FOR [OBS_LIB]

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ]  WITH CHECK ADD  CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO] FOREIGN KEY([CD_CTR])
REFERENCES [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO] ([CD_CTR])

ALTER TABLE [dbo].[EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ] CHECK CONSTRAINT [FK_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO_TIPO_BLQ_EST_NF_ENT_DANFE_PROVISORIO_LIBERACAO]
end
