Last active
February 27, 2022 14:59
-
-
Save data-goblin/905dbc795e4d1adacfeb3318bd3f2c8e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////////////////////////////////////////////////////// | |
// | |
// Evaluates a DMV to determine the last time the model was processed (refreshed) | |
// | |
// Original method from Marco Russo https://www.sqlbi.com/articles/last-process-date-in-ssas-tabular/ | |
// | |
///////////////////////////////////////////////////////////////////////////////////////////// | |
// Query to be evaluated | |
string _dmv = "SELECT TOP 1 [LAST_DATA_UPDATE] FROM $SYSTEM.MDSCHEMA_CUBES"; | |
// Evaluate the query | |
using(var daxReader = ExecuteReader(_dmv)) | |
{ | |
// Read the results | |
while(daxReader.Read()) | |
{ | |
var rowValues = new object[daxReader.FieldCount]; | |
daxReader.GetValues(rowValues); | |
var row = rowValues.Select(v => v == null ? "" : v); | |
// Convert the scalar value to a string | |
string _processdate = row.ElementAt(0).ToString(); | |
Info ( "The model was last processed at " + _processdate); | |
} | |
// Close the reader | |
daxReader.Close(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment