# Connecting to SQL Server

**URL:** <https://www.ruby-forum.com/t/connecting-to-sql-server/147710>\
**Category:** Ruby\
**Created:** [September 4, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/connecting-to-sql-server/147710 "2008-09-04T14:26:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clinton\_DSJudy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Clinton\_DSJudy](https://www.ruby-forum.com/u/Clinton_DSJudy)\
**Post date:** [September 4, 2008, 2:26pm UTC](https://www.ruby-forum.com/t/connecting-to-sql-server/147710/1 "2008-09-04T14:26:52Z")

</div>

So ActiveRecord has failed me. The sqlserver module isn’t complete, and  
I’m getting “zombie state” errors, essentially because Rails wants to  
maintain a connection to SQL server and SQL server is used to [ASP.net](http://ASP.net)  
making connections to the server for every request. (Yuck, but that’s  
what I have to work with here.) Is there a ruby gem that’s been  
maintained to use SQL Server better? I can’t find one, but someone’s  
gotta be working on one with how common SQL Server is.

I don’t even use most of the “cool” features ActiveRecord has as I have  
a DBA here who insists on using stored procedures for everything. That’s  
an industry standard, but not the Rails way, and thus another roadblock  
in my Rails application.

If there isn’t anything, I’ll research creating my own gem to do the  
task. Obviously I’d rather not duplicate efforts. Thanks!

Clinton Judy

Web D.

Glenn O. Hawbaker, Inc.

---

<div class="post-metadata">

**Author:** ![Clinton\_DSJudy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Clinton\_DSJudy](https://www.ruby-forum.com/u/Clinton_DSJudy)\
**Post date:** [September 9, 2008, 9:25am UTC](https://www.ruby-forum.com/t/connecting-to-sql-server/147710/2 "2008-09-09T09:25:23Z")

</div>

On Sep 4, 2:20 pm, “Clinton D. Judy” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> an industry standard, but not the Rails way, and thus another roadblock  
> in my Rails application.
> 
> If there isn’t anything, I’ll research creating my own gem to do the  
> task. Obviously I’d rather not duplicate efforts. Thanks!
> 
> Clinton Judy
> 
> Web D.
> 
> Glenn O. Hawbaker, Inc.

I am too often in same situation. For this I use the activerecord-  
sqlserver-adapter.  
Kipping the business logic in SQL stored procedures is a product of  
one development school.  
Do not want to enter in discussion about pros and cons of that  
decision but it’s a reality of life.  
Thing that bother me even more is a column naming convention that is  
usually used in MS SQL databases.  
In almost all my Models has to explicitly define a table name and a  
primary key name.

However, I have managed to communicate with MS SQL in satisfactory  
faction.

---

<div class="post-metadata">

**Author:** ![Clinton\_DSJudy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/e0b2c6/32.png) [@Clinton\_DSJudy](https://www.ruby-forum.com/u/Clinton_DSJudy)\
**Post date:** [September 9, 2008, 2:49pm UTC](https://www.ruby-forum.com/t/connecting-to-sql-server/147710/3 "2008-09-09T14:49:37Z")

</div>

Actually, last night I JUST figured out a solution. I wrapped all of my  
connection.select\_alls in connection.transactions. Done. Somehow, Rails  
closes the objects properly for SQL Server when I do that.

Hopefully that helps someone. 🙂
