USE $(DATA_BASE_NAME);
GO

DROP VIEW [drtrpt].[DartRequestEvent]
GO

/****** Object:  View [drtrpt].[DartRequestEvent]    Script Date: 2/24/2016 1:58:21 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE view [drtrpt].[DartRequestEvent]
as
select
                 req.ActivityID as ResearchStudyID
                 , req.ID as REquestID
                 , req.TrackingNumber
                 , e.ID as EventID
                 , e.CreatedOn as EventDate
                 , e.Name as EventName
                 , e.Description as EventDescription
                 , et.Name as EventType

from hib.Request req
       inner join hib.[Event] e on req.ID = e.RequestID
       inner join hib.eventType et on e.EventTypeID = et.ID
--order by req.ActivityID, req.ID


GO