14

Apologies if this has been answered already but I have yet been unable to find an answer :(

I'm using SQL Server Management Studio 2008 on Windows 7 box.

I right-click any sproc, function or object and choose "Modify".
I click "Save" and save the file to a folder that is a git repository on my local hard drive.
I save the file as suggested type = "Microsoft SQL Server Query File (.sql)
So now I have a file e.g. "MySproc.sql" which opens fine in SQL Management studio, however when I use Git GUI and do a "scan" to find modified files it presents my new "MySProc.sql" as "* Binary file (not showing content)." instead of simple text.

I've tried opening the file in NOtepad and re-saving it but that did not fix it.

Any help would be greatly appreciated.

1

3 Answers 3

14

Just a guess, but I would say your .sql file is UTF-16; If you were to save it as UTF-8 or ASCII, I imagine git gui would work properly with it.

Sign up to request clarification or add additional context in comments.

5 Comments

When I open any file in Notepad and "save-as" it shows the file encoding as "ANSI"... pardon my lack of knowledge but how can I see the encoding of a file?
best option is to use a decent text editor. Notepad++ and PSPAD are two free options that would tell you what you need to know.
@Tao, @Andre: SQL Management Studio supports saving using different encodings. When you do Save As, click the down-arrow on the Save button, and select 'Save with Encoding...'.
@Andre: Keep in mind if the original file in the repository is UTF-16, then the new version being UTF-8 or ASCII won't make the comparison work. If this is the issue, your best bet is probably to use a different tool for comparing, one that supports Unicode.
In SQL Management Studio 2012, the option is File -> Advanced save settings.
1

It is annoying, but what I do is change the extension to .txt before uploading changes. I think the .sql extension is what is tripping up git.

P.S. Here's a valuable tip if you are using SQL Server Management Studio. Right click on your database. Choose Tasks from the popup menu and then Generate Scripts. That brings you into a wizard where you can generate scripts for everything in your database. You can output all scripts into a single folder. Then use a program like oscar's renamer to change the extension to .txt before you commit your changes. It is a great way to add source control (albeit manual) to your database.

Comments

1

You can also use powershell to convert the file to ASCII.

Get-Content Filename.sql | Out-File NewFileName.sql -Encoding ascii

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.