TabularEditor / TabularEditorDocs

This is the articles for the Tabular Editor documentation site, https://docs.tabulareditor.com
12 stars 13 forks source link

Update Useful-script-snippets.md #44

Closed Daandamhuis closed 1 year ago

Daandamhuis commented 1 year ago

This part prevents the script from crashing if other sources, like Excel or Json, are present in the model.

if (p.Expression.Contains("Source = Sql.Database"))
{
    var oldServer = "\"" + GetServer(p.Expression) + "\"";
    var oldDatabase = "\"" + GetDatabase(p.Expression) + "\"";
    p.Expression = p.Expression.Replace(oldServer, server).Replace(oldDatabase, database);
}
otykier commented 1 year ago

Thanks for your contribution!