Overview
The default encoding for SSMS sql files is UTF-16, more specifically, either Western European (Windows) - Codepage 1252 or Unicode - Codepage 1200. These encodings play havoc with a git diff as these encoding appear as binary files.
The preferred encoding is Unicode (UTF-8 with asignature) - Codepage 65001
Steps to resolve
- From within SSMS, open the sql template file named
SQLFile.sql, by default in one of these locations: –%ProgramFiles%\Microsoft SQL Server\[Sql Version]\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\%ProgramFiles(x86)%\Microsoft SQL Server\[Sql Version]\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\%ProgramFiles%\Microsoft SQL Server\[Sql Version]\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql%ProgramFiles(x86)%\Microsoft SQL Server\[Sql Version]\Tools\Binn\ManagementStudio\SqlWorkbenchProjectItems\Sql
- Resave using correct encoding:
- File => Save As
- Click the arrow next to the Save button
- Choose the relevant encoding:
Unicode (UTF-8 with asignature) - Codepage 65001
All new query windows will default to UTF-8 files