You're getting that because the file is marked as executable. The file manager is just saying "hey! do you want me to run this as a program, or open it as a text file?"
Does it open in GEdit properly if you click "Display"? If so, your file associations are set correctly. You can then get rid of this extra dialog with one of the following:
Follow mrucci's answer to tell Nautilus to just display executable text files instead of offering to run them. OR...
Remove the executable permission from the file if it doesn't need it. Run chmod -x myfile.sql on the file to remove the executable bit. Then Nautilus won't offer to run it.
The second option is not doable with chmod on FAT32 or NTFS filesystems. You'd have to mount the drives with certain mount options (eg -o noexec) to get the same effect.
Edit: There is a third option. Instead of double-clicking to auto-open the files, get into the habit of right-clicking and choosing the "Edit" option. This is what I do on Windows with .bat files, and in Thunar on Xubuntu with shellscripts (.sh) -- I don't know offhand but I'd expect the default file manager in Ubuntu can do this too. It's a good habit to get into -- even if I tweak my computer to behave "properly", someone else's system won't behave the same.