-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Comments] SSMS Keyboard Query Shortcuts #7
Comments
Hey, I just wanted to say this article is great! I also found another potentially useful shortcut which would look like the following: "IF @@ServerName != N'YourDevServer' BEGIN RAISERROR(N'You''re not on the development server, by the way. This batch will abort.', 16, 1); RETURN; END; " You don't actually pass a parameter into it - you would just use it as an F5 replacement when you want to execute unrelated queries. Steve |
@Glasses93 haha! Too funny. (regarding the I even thought about re-mapping |
Great stuff! Love the poor man's snippet deal too! |
Hey There! Great stuff, but I am having an issue with one and I have no idea why? I have this assigned to Crtl+8: SELECT FORMAT(COUNT(*),'N0')AS Row_Count FROM [space] But when I highlight a table name, or a schema and a table name, I get....nothing. I've pasted the actual SQL into a query widow and executed it, which runs fine. So not sure. Thanks! |
Have you opened a new query since assigning the shortcut? |
Aaaaaahhhh! That did it!! Didn't even think of that! Thank you! |
Just wrote up this script-let for my new v20 install. Does the backup and has error handling if the [CmdletBinding()]
param (
)
$queryXml = @'
<Element>
<Key>
<int>-1</int>
</Key>
<Value>
<string />
</Value>
</Element>
<Element>
<Key>
<int>3</int>
</Key>
<Value>
<string>sp_WhoIsActive @format_output = 2</string>
</Value>
</Element>
<Element>
<Key>
<int>4</int>
</Key>
<Value>
<string>sp_BlitzFirst</string>
</Value>
</Element>
<Element>
<Key>
<int>5</int>
</Key>
<Value>
<string>SELECT TOP (100) * FROM </string>
</Value>
</Element>
<Element>
<Key>
<int>6</int>
</Key>
<Value>
<string>sp_helpme </string>
</Value>
</Element>
<Element>
<Key>
<int>7</int>
</Key>
<Value>
<string>sp_BlitzWho</string>
</Value>
</Element>
<Element>
<Key>
<int>8</int>
</Key>
<Value>
<string>sp_WhoIsActive @format_output = 2 , @get_plans = 1 , @get_outer_command = 1 , @find_block_leaders = 1 , @sort_order = N'[blocked_session_count] DESC, [start_time]'</string>
</Value>
</Element>
<Element>
<Key>
<int>9</int>
</Key>
<Value>
<string />
</Value>
</Element>
<Element>
<Key>
<int>0</int>
</Key>
<Value>
<string />
</Value>
</Element>
'@
# Number 20.0 changes with version
$ssmsUserSettingsDirectory = "$env:APPDATA\Microsoft\SQL Server Management Studio\20.0"
$ssmsUserSettingsFile = Join-Path $ssmsUserSettingsDirectory "UserSettings.xml"
$ssmsUserSettingsBackupFile = Join-Path $ssmsUserSettingsDirectory "UserSettings_backup_$(date -Format "yyyyMMdd_HHmmssfff").xml"
Copy-Item $ssmsUserSettingsFile $ssmsUserSettingsBackupFile
[xml]$xmlDoc = Get-Content $ssmsUserSettingsFile
$qeSettings=$xmlDoc.SqlStudio.SSMS.QueryExecution;
$queryShortcutsElement = $qeSettings.SelectSingleNode('QueryShortcuts')
if (-not $queryShortcutsElement) {
Write-Error "Cannot find Query Shortcuts element. Xml Schema might have changed."
return
}
$queryShortcutsElement.InnerXml = $queryXml
$xmlDoc.Save($ssmsUserSettingsFile) |
https://chadbaldwin.net/2021/01/21/ssms-keyboard-query-shortcuts
The text was updated successfully, but these errors were encountered: