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

3 votes
Accepted answer

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 votes
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
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

197 views 3 6
Read article

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