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.

Jon Seigel
  • 12,251
  • 8
  • 58
  • 92
Andre
  • 790
  • 1
  • 9
  • 25
  • Possible duplicate (unanswered though): http://stackoverflow.com/questions/3915072/git-gui-can-it-be-made-to-display-utf16 – Chris Shaffer May 05 '11 at 16:56

3 Answers3

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.

Chris Shaffer
  • 32,199
  • 5
  • 49
  • 61
  • 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? – Andre May 05 '11 at 17:00
  • 1
    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 May 05 '11 at 18:19
  • @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...'. – Jon Seigel May 08 '11 at 19:16
  • @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. – Chris Shaffer May 08 '11 at 20:05
  • 1
    In SQL Management Studio 2012, the option is File -> Advanced save settings. – Danny Frencham Jun 04 '13 at 01:42
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.

paulstamant
  • 43
  • 10
1

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

Get-Content Filename.sql | Out-File NewFileName.sql -Encoding ascii
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
Mike Smith
  • 11
  • 1