
IF NOT EXISTS
	(SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT')
BEGIN

	CREATE TABLE [dbo].[EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT](
		[CD_EMP] [INT] NOT NULL,
		[CD_MOV_OP] [INT] NOT NULL,
		[CD_USU] [INT] NOT NULL,
		[DS_TBL_DESC] [varchar](150) NULL,
		[DT_CAD] DATETIME NOT NULL,
		[NM_PROGRAMA] [varchar](1000) NULL,
		[HOST] [varchar](1000) NULL,
		[IP] [sql_variant] NULL
	 CONSTRAINT [PK_EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT] PRIMARY KEY CLUSTERED 
	(
		[CD_EMP] ASC,
		[CD_MOV_OP] 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_VALID_NATUREZA_DANFE_AUDIT] ADD  
		CONSTRAINT [DF_EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT_HOST_PROGRAM_NAME]  DEFAULT (program_name()) FOR [NM_PROGRAMA]

	ALTER TABLE [dbo].[EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT] ADD  
		CONSTRAINT [DF_EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT_HOST]  DEFAULT (host_name()) FOR [HOST]

	ALTER TABLE [dbo].[EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT] ADD  
		CONSTRAINT [DF_EST_NF_ENT_VALID_NATUREZA_DANFE_AUDIT_IP_CLIENTE]  DEFAULT (connectionproperty('CLIENT_NET_ADDRESS')) FOR [IP]

END;

