Skip to content

Instantly share code, notes, and snippets.

@ffabreti
Last active August 29, 2015 14:04
Show Gist options
  • Save ffabreti/6f26b7e4a42ff502dfc8 to your computer and use it in GitHub Desktop.
Save ffabreti/6f26b7e4a42ff502dfc8 to your computer and use it in GitHub Desktop.
connecting thru tiny_tds via cli:
sudo yum install freetds
/etc/freetds.conf -> set tds version! (on ubuntu it was /etc/freetds/freetds.conf and didn't work until set the version to 8.0
$ TDSVER=7.1 tsql -H servername -p 1433 -U domain\\user.name -P `cat pass.txt`
try with TDSVER=8.0 too...
-------------------------------------------
installing tiny_tds gem:
sudo yum install freetds-devel
rvm use 2.0.0
gem install tiny_tds --platform=ruby --no-ri --no-rdoc #--platform to recompile native
-------------------------------------------
using rails-sqlserver-adapter:
Gemfile:
gem 'sqlite3'
gem 'tiny_tds'
gem 'activerecord-sqlserver-adapter'
database.yml:
development:
adapter: sqlserver
database: DBCAGED
username: domain\\user.name
password: yourpass
host: servername
port: 1433
timeout: 180000
-------------------------------------------
Problem with unicode and SQLServer ignores INDEXES
http://stackoverflow.com/questions/24828451/activerecord-sqlserver-adapter-unicode-slow-performance
MyModel.find_all_by_NRPIS '12700333166'
MyModel Load (85869.3ms) EXEC sp_executesql N'SELECT [MyTable].* FROM [MyTable] WHERE [MyTable].[NRPIS] = N''12700333166'''
a = MyModel.where "NRPIS = ?", '12700233166'.force_encoding("ISO-8859-1")
MyModel Load (53.1ms) EXEC sp_executesql N'SELECT [MyTable].* FROM [MyTable] WHERE (NRPIS = ''12700193166'')'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment