How To: Rails with SQL Server 2008

November 1, 2009

Most common database used with Rails is mySQL but if you ever need to use SQL Server, here is a quick how to.

I am using  Windows Vista, SQL Server 2008, Rails 2.2.

1)  Install  activerecord-sqlserver-adapter gem

 > gem install activerecord-sqlserver-adapter

 Capture1

2) Create a new Login for this new database (say testuser) using SQL Server Management Studio

Capture3

3) Create a new database in SQL Server 2008 for your project (say testproject) and choose testuser as Owner

Capture3

4) Create a new ODBC DNS

Control Panel -> Administrative Tools -> Data Sources (ODBC)

Capture5

Add a new ‘User DSN’,  choose SQL Server,  give a name for DSN (say testprojectconn) then configure SQL Server authentication.

5) Now create your rails application as usual.  Configure db connection using database.yml as follows

  adapter: sqlserver
  mode: odbc
  dsn: testprojectconn
  host: localhost
  username: testuser
  password: testpass
  encoding: utf8

Thats it!

About these ads

2 Responses to “How To: Rails with SQL Server 2008”


  1. [...] dati (ad esempio testuser) utilizzando SQL Server Management Studio 3) Creare un nuovo [...] From: N Rao Lakkakula’s Blog. Continue reading. Categorie:Senza categoria Tag: Commenti (0) Trackbacks (0) Lascia un [...]

  2. Anonymous Says:

    thank you~


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: