SQL Server Management Studio saves .sql file with binary character

1.9k Views Asked by At

While saving .sql files from SQL Server Management Studio in to my local windows folder, it looks to be including some binary characters making AccuRev comparisons impossible. I looked for possible save options and couldn't locate any. and couldn't find any. Any suggestions please?

3

There are 3 best solutions below

2
marc_s On BEST ANSWER

If you can't tell AccuRev to handle this as UTF-8 files (this sucks - these days, all software should really know about UTF-8 and handle it correctly!), then you might need to do something in SQL Server Management Studio instead.

When you have a SQL statement open and you click on "File > Save", in the "Save" dialog, there is a little down-arrow to the right of the Save button:

enter image description here

If you click that (instead of just clicking on the button itself), you can select "Save with Encoding", which allows you to pick what encoding to use for your files - pick something like the Windows-1252 Western European - that should not have any UTF-8 Byte-Order Mark bytes at the start:

enter image description here

0
Mike Abusheery On

AccuRev does handle UTF-8 character encoding. However, older versions may not have that capability.

Make sure that the file is being saved using UTF-8. Anything else will have binary content and should be typed as such.

0
jms333 On

When you export sql files from MS SQL Server Management Studio in unicode (by default), it puts a "FF FE BOM" at the front of the file which forces programs to treat it as binary. Exporting as ANSI solved it. Choose "Save as ANSI Text".