# What's the right adapter to use for SQL Server?

**URL:** <https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735>\
**Category:** Rails\
**Created:** [April 28, 2010, 3:10pm UTC](https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735 "2010-04-28T15:10:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [April 28, 2010, 3:10pm UTC](https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735/1 "2010-04-28T15:10:23Z")

</div>

I am porting a Rails app that is made up of 2 rails projects to SQL  
Server. The app already runs with MySQL and Oracle. One Rails project is  
the UI with a database that contains user/project specific data. The  
second Rails project is the database server for the main data. The UI  
makes REST calls to the database to get data to display. There is a list  
of product lines that is used on a search screen so the user chooses  
which product line to search. My problem is that with SQL Server as the  
database, about 80% of the time an exception gets thrown after the first  
product line data is returned. The message from the exception is  
“undefined method `name’ for nil:NilClass”.

This problem does not happen with MySQL nor Oracle as the database. So,  
it appears to be something to do with the database. I am using  
activerecord-sqlserver-adapter with a system DSN to connect to the  
database. I also had to move from Ruby 1.8.7 back to 1.8.6 to get the  
adapter to work at all. I have seen references to using ADO or ODBC  
instead.

So my questions are:

1. Has anybody else had a similar problem?
2. What database adapter is the proper one to use with SQL Server?

Thanks in advance!  
Norm

---

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [April 28, 2010, 7:17pm UTC](https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735/2 "2010-04-28T19:17:50Z")

</div>

Aside from the migrations and database.yml, have you changed any other  
code in the app?

---

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [April 28, 2010, 7:34pm UTC](https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735/3 "2010-04-28T19:34:50Z")

</div>

command0 wrote:

> Aside from the migrations and database.yml, have you changed any other  
> code in the app?

Nope, same code.

I am truly impressed with the portability of Rails apps! I did most of  
my development with JRuby in Ubuntu. The other developer used  
Ruby/Windows. The app runs on MySQL, Oracle, and SQL server from the  
same code base. Unless an app does something strange, other than getting  
a new environment set up and tweaking the config files, is about all you  
have to do.

---

<div class="post-metadata">

**Author:** ![nlsmith](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/43a26b/32.png) [@nlsmith](https://www.ruby-forum.com/u/nlsmith)\
**Post date:** [April 28, 2010, 11:32pm UTC](https://www.ruby-forum.com/t/whats-the-right-adapter-to-use-for-sql-server/187735/4 "2010-04-28T23:32:49Z")

</div>

> So my questions are:
> 
> 1. Has anybody else had a similar problem?
> 2. What database adapter is the proper one to use with SQL Server?
> 
> Thanks in advance!  
> Norm

I am using only simple access to MS SQL I also find out how to call  
procedures. No problems so far.

ODBC is the only working way. Be it on Windows or Linux. Although it is  
not so trivial to install support on Linux it can be done (I am the  
proof 😉

Search for “ruby odbc freetds” on google.

by  
TheR
