yka9da
Last Updated: February 25, 2016
·
2.774K
· ChrisMissal
3c4478e6ae6c60b73d21c9fa0d1785ea

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.

Picture

You can prevent this by "Save with Encoding..." as shown below. Just click the down arrow on the save button.

Picture

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!

Say Thanks
Respond

2 Responses
Add your response

12224
D3b2094f1b3386e660bb737e797f5dcc

Yeah, UTF-16 .sql files were annoying for me with GitHub diffs.

There is an easier way to make this problem go away:

  1. 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\.
  2. Resave (using your tip) as UTF-8.
  3. 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).

over 1 year ago ·
12226
3c4478e6ae6c60b73d21c9fa0d1785ea

This is perfect, thanks Steve!

over 1 year ago ·
Filed Under