# Ruby-DBI to query MS SQL 2003 ? (newb)

**URL:** <https://www.ruby-forum.com/t/ruby-dbi-to-query-ms-sql-2003-newb/52181>\
**Category:** Ruby\
**Created:** [January 11, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/ruby-dbi-to-query-ms-sql-2003-newb/52181 "2006-01-11T19:36:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josiah\_Ritchie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71c47a/32.png) [@Josiah\_Ritchie](https://www.ruby-forum.com/u/Josiah_Ritchie)\
**Post date:** [January 11, 2006, 7:36pm UTC](https://www.ruby-forum.com/t/ruby-dbi-to-query-ms-sql-2003-newb/52181/1 "2006-01-11T19:36:47Z")

</div>

I’m trying to write a script to pull data out of a MS SQL 2003  
database and manipulate it a bit. I’ve found ActiveRecord to be slim  
on examples outside of the Rails environment.

I’ve tried lots of variations on the name of the driver; mssql, msql,  
mysql examples.

dbh = DBI.connect(“dbi:msql:wbctest:chad”, “testuser”, “testpass”)

I’ve dug into the dbi code some, found that it is case-insensitive  
and, I believe, confirmed that msql is the appropriate one for my  
needs and that it exists under the DBD directory.

Maybe I’m making this harder than it needs to be? That would be  
common. I will gladly accept corrections in my direction of attack.

JSR/

---

<div class="post-metadata">

**Author:** ![Josiah\_Ritchie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71c47a/32.png) [@Josiah\_Ritchie](https://www.ruby-forum.com/u/Josiah_Ritchie)\
**Post date:** [January 11, 2006, 8:44pm UTC](https://www.ruby-forum.com/t/ruby-dbi-to-query-ms-sql-2003-newb/52181/2 "2006-01-11T20:44:08Z")

</div>

I think you want something more like this:

DBI:ADO:Provider=SQLOLEDB;Data Source=YOURSERVER;Initial  
Catalog=YOURDB;User Id=YOU;Password=YOURPASSWORD;

You may be able to leave the user and pw out of the above string if  
you include them in the 2nd and 3rd args to connect.

You’ll probably need to download the ADO adapter and add it to your  
Ruby install. For some reason, it doesn’t come with the windows Ruby  
installer, although DBI does.

You can get it from  
[http://rubyforge.org/frs/download.php/655/ruby-dbi-all-0.0.23.tar.gz](http://rubyforge.org/frs/download.php/655/ruby-dbi-all-0.0.23.tar.gz).  
Just pull the file “ADO.db” out and stick it in  
\lib\ruby\site\_ruby\1.8\DBD\ADO. (You’ll have to create the  
ADO directory.)

Jim

---

<div class="post-metadata">

**Author:** ![Josiah\_Ritchie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71c47a/32.png) [@Josiah\_Ritchie](https://www.ruby-forum.com/u/Josiah_Ritchie)\
**Post date:** [January 11, 2006, 10:22pm UTC](https://www.ruby-forum.com/t/ruby-dbi-to-query-ms-sql-2003-newb/52181/3 "2006-01-11T22:22:00Z")

</div>

thanks, I’ll work on that.
