IF NOT EXISTS(SELECT 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='GLB_AGEND_LOJA') 
BEGIN
	CREATE TABLE [DBO].[GLB_AGEND_LOJA](
		[CD_AGEND] [INT] IDENTITY(1,1) NOT NULL,
		[DS_AGEND] [VARCHAR](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
		[TP_AGEND] [INT] NOT NULL,
		[PRZ_AGEND] [INT] NOT NULL,
		[HR_AGEND] [VARCHAR](5) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
		[DS_MOTIVO_AGEND] [VARCHAR](100) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
		[CD_USU] [INT] NOT NULL,
		[DT_CAD] [DATETIME] NOT NULL,
		[DT_ULT_ALT] [DATETIME] NULL,
		[QUERY_AGEND] [VARCHAR](8000) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	 CONSTRAINT [PK_GLB_AGEND_LOJA] PRIMARY KEY CLUSTERED 
	(
		[CD_AGEND] 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].[GLB_AGEND_LOJA]  WITH CHECK ADD  CONSTRAINT [FK_GLB_AGEND_LOJA_GLB_USU] FOREIGN KEY([CD_USU])
	REFERENCES [dbo].[GLB_USU] ([CD_USU])
	
END
