-- Crear tabla de Agenda en Asurnet: será agenda de usuarios
CREATE TABLE asurnet.dbo.AGENDA_USUARIOS (
	AGN_ID int IDENTITY(1,1) NOT NULL,
	AGN_Fecha datetime NULL,
	AGN_Hora varchar(5) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	AGN_Situacion smallint NULL,
	AGN_UsuarioDestino int NULL,
	AGN_Prioridad smallint NULL,
	AGN_TipoObjeto smallint NULL,
	AGN_ObjetoID varchar(30) NULL,
	USR_Id_FC int NOT NULL,
	USR_Id_FM int NOT NULL,
	AGN_FC datetime NOT NULL,
	AGN_FM datetime NOT NULL,
	AGN_Descripcion varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	AGN_AliasObjeto varchar(255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	CONSTRAINT PK_AGENDA_USUARIOS PRIMARY KEY (AGN_ID)
);
CREATE NONCLUSTERED INDEX IND_AGN_Objeto ON asurnet.dbo.AGENDA_USUARIOS (  AGN_TipoObjeto ASC  , AGN_ObjetoID ASC  )
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ];
CREATE NONCLUSTERED INDEX IND_FC_USRFC_OBJID_TIPOOBJ ON asurnet.dbo.AGENDA_USUARIOS (  AGN_FC ASC  , USR_Id_FC ASC  , AGN_ObjetoID ASC  , AGN_TipoObjeto ASC  , AGN_ID DESC  )
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ];
CREATE NONCLUSTERED INDEX IND_SITUACION_FECHA ON asurnet.dbo.AGENDA_USUARIOS (  AGN_Situacion ASC  , AGN_Fecha ASC  , AGN_ID ASC  , AGN_Hora ASC  )
	 WITH (  PAD_INDEX = OFF ,FILLFACTOR = 100  ,SORT_IN_TEMPDB = OFF , IGNORE_DUP_KEY = OFF , STATISTICS_NORECOMPUTE = OFF , ONLINE = OFF , ALLOW_ROW_LOCKS = ON , ALLOW_PAGE_LOCKS = ON  )
	 ON [PRIMARY ];
