How to change file type from binary to text for .sql file

hello,

I've added a sql file via TortoiseHg to my Mercurial repository and it went in a a binary file rather than text.

1) Can I change it to text so that I can see revision changes through the web interface like all my other source files?

2) Was there something I missed when adding which caused this?

Thank you.

3 answers

1 accepted

The problem turns out to be that the file was created in unicode rather than ansi text encoding by SQL Server Management Studio. It was a default option on the export task.

Mercurial does not play nicely with it and adds it to the repository as a binary file which will not allow previewing or diffs from TortoiseHg or the web interface.

So, to answer my original question of how to change it after it has been added, I opened it in notepad and saved it as an ANSI file. Now it works.

0 vote
Jason Worley Atlassian Team Feb 22, 2013

Greetings!

SQL files, like images (.jpg, etc) are generally transferred over SSH, FTP and SCP in binary (BIN) format.

The standard approach would be to load the SQL file into a local DB such as MySQL and from there you can select data as well as export data.

If you really want to convert the data to text format, most likely your best bet is to research/find/download a 3rd party application or you might get lucky by using wordpad or other word editors.

For 3rd party solutions, I just did a google search and found several hits, for example: http://convert.software.informer.com/download-convert-sql-file-to-text-file/

I hope this response was helpful.

Cheers,
Jason | Atlassian

In case someone who runs across this has a lot of these files, like I did, you could run this PowerShell script to update all of your .SQL files at once.

Get-ChildItem -Recurse *.sql | foreach {
$FileName = $_.FullName;
[System.Io.File]::ReadAllText($FileName) | Out-File -FilePath $FileName -Encoding UTF8;
}

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

28,244 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you