Skip to content

Instantly share code, notes, and snippets.

@chadbaldwin
Created July 24, 2020 20:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chadbaldwin/026318b78ac26199211267e5a3efebfa to your computer and use it in GitHub Desktop.
Save chadbaldwin/026318b78ac26199211267e5a3efebfa to your computer and use it in GitHub Desktop.
# Dark Theme
$file = gi "${env:ProgramFiles(x86)}\Microsoft SQL Server Management Studio 18\Common7\IDE\ssms.pkgundef"; ($file | gc) -Replace '(.*{1ded0138-47ce-435e-84ef-9ec1f439b749})', '//$1' | Out-File $file;
# Query execution settings
$ssmsUserSettingsFile = "$($env:APPDATA)\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml";
$newXml = "<Element><Key><int>-1</int></Key><Value><string /></Value></Element>
<Element><Key><int>3</int></Key><Value><string /></Value></Element>
<Element><Key><int>4</int></Key><Value><string /></Value></Element>
<Element><Key><int>5</int></Key><Value><string>USE </string></Value></Element>
<Element><Key><int>6</int></Key><Value><string>SELECT FORMAT(COUNT(*),'N0') FROM </string></Value></Element>
<Element><Key><int>7</int></Key><Value><string>SELECT TOP(100) * FROM </string></Value></Element>
<Element><Key><int>8</int></Key><Value><string>SELECT * FROM </string></Value></Element>
<Element><Key><int>9</int></Key><Value><string>SELECT </string></Value></Element>
<Element><Key><int>0</int></Key><Value><string /></Value></Element>"
# Open file
[xml]$xmlDoc = gc $ssmsUserSettingsFile; $QESettings=$xmlDoc.SqlStudio.SSMS.QueryExecution;
# Set Settings
($QESettings.SelectSingleNode("QueryShortcuts")).InnerXml=$newXml;
$QESettings.ExecutionSettings.SetTransactionIsolationLevel="READ UNCOMMITTED";
$QESettings.ExecutionSettings.SetDeadlockPriorityLow="true";
$QESettings.ExecutionResults.RetainCRLFOnCopyOrSave="true";
# Save file, then re-open and save to format
$xmlDoc.Save($ssmsUserSettingsFile); [xml]$xmlDoc = gc $ssmsUserSettingsFile; $xmlDoc.Save($ssmsUserSettingsFile);
@chadbaldwin
Copy link
Author

[reserving first comment]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment