SQL Rob

SQL Server and other database technologies

Reference

SSMS Shortcuts:
New Query Window: ctrl + N
Toggle between open query windows: ctrl + F6
Toggle between tabs on results window: F6
Close query window: ctrl + F4
Results Pane on/off: ctrl + R
Object Explorer: F8
Run Query: F5
Stop running query: alt + break
Parse Query: ctrl + F5
Save: ctrl + S
Select multiple lines to edit all lines at once – add commas to all lines, etc.: alt + shift + arrow
Change server connection: ctrl + F7
Change database: ctrl + U

Windows Shortcuts:
Shift + F10 – Right click menu
Alt + Up Arrow – Go up a level in File Explorer

CONVERT – Date Codes:
101: mm/dd/yyyy
110: mm-dd-yyyy
112: yyyymmdd
120: yyyy-mm-dd hh:mi:ss
121: yyyy-mm-dd hh:mi:ss.mmm
127: yyyy-mm-ddThh:mi:ss.mmmZ

https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-2017

Format Dates – Custom:
yyyy-MM-dd HH-mm:ss.fff – 2019-04-04 17:25:02.193
gg – Era (AD/BC)
tt – AM/PM
zz – Hours offset from UTC

https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

Format Number:
FORMAT(123, ‘00000’) = 00123
FORMAT(123, ‘#####’) = 123

Hex: FORMAT(255, ‘X’) = FF
Percent: FORMAT(.45, ‘P’) = 45.00 %
Currency: FORMAT(123.45, ‘C’) = $123.45

Powershell:
Set-ExecutionPolicy RemoteSigned – run as admin
Set-ExecutionPolicy Unrestricted -Scope CurrentUser
Get-ExecutionPolicy -List

Command Line Commands:
cd: Change Directory
cls: Clear Screen
del: Delete Files
dir: List Directory Content
mkdir: Create Directory
move: Move files
netstat: Display Connections
pause: Pause Execution
rd: Remove Directory
xcopy: Copy Files