Skip to content

Instantly share code, notes, and snippets.

@Alexei000
Created September 5, 2017 14:30
Show Gist options
  • Save Alexei000/f81c6894e9b7650535c733ca66864326 to your computer and use it in GitHub Desktop.
Save Alexei000/f81c6894e9b7650535c733ca66864326 to your computer and use it in GitHub Desktop.
Object fetch with joins view
create view tmp.vwImportingSystemTestResult
AS
SELECT TR.ImportingSystemTestResultId, TR.EnteredTimestamp, TR.RunTimestamp, TR.ImportingSystemTestId, TR.ImportingSystemId, TR.EnvironmentId, TR.RequesterId, TR.ImportingSystemTestExecutionStatusId,
TR.ResultFilename, Q.RequestId, DurationMs,
T.TestName, ImpSys.ImportingSystemName, E.Name, U.Username
FROM dbo.ImportingSystemTestResult TR
JOIN dbo.ImportingSystemTestRunTime TRT ON TRT.ImportingSystemTestResultId = TR.ImportingSystemTestResultId
JOIN dbo.ImportingSystemTestQueue Q ON Q.ImportingSystemTestQueueId = TR.ImportingSystemTestQueueId
-- names joins
JOIN dbo.ImportingSystemTest T ON T.ImportingSystemTestId = TR.ImportingSystemTestId
JOIN dbo.ImportingSystem ImpSys ON ImpSys.ImportingSystemId = T.ImportingSystemId
JOIN dbo.Environment E ON E.EnvironmentId = TR.EnvironmentId
JOIN dbo.AppUser U ON U.AppUserId = TR.RequesterId
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment