Better Diffs with SQL Files
The default encoding for SQL Server Management Studio is UTF-16. If you are saving a file with this encoding, some diff tools or viewers "think" the file is binary and won't give you a comparison.
You can prevent this by "Save with Encoding..." as shown below. Just click the down arrow on the save button.
Now you'll be able to see diffs in GitHub (for instance).
I hope this is helpful, but if you know another way, or better way, I'd love to know about it, thanks!
Written by Chris Missal
Related protips
2 Responses
Yeah, UTF-16 .sql files were annoying for me with GitHub diffs.
There is an easier way to make this problem go away:
- Find the template is a file named
SQLFile.sql
, by default in the location%ProgramFiles%\Microsoft SQL Server\[Sql Version]\Tools\Binn\VSShell\Common7\IDE\SqlWorkbenchProjectItems\Sql\
. - Resave (using your tip) as UTF-8.
- All new query windows will default to UTF-8 files
Source: Microsoft Connect post Unicode Defaults on SSMS Save.
There is a great read at UTF-8 Everywhere explaining why Microsoft is so wedded to UTF-16 (aka "Unicode" in the Microsoft developer world).
This is perfect, thanks Steve!