# Database migration

**URL:** <https://www.ruby-forum.com/t/database-migration/90720>\
**Category:** Rails\
**Created:** [March 31, 2007, 2:19pm UTC](https://www.ruby-forum.com/t/database-migration/90720 "2007-03-31T14:19:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PaSSS\_lo\_Geyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@PaSSS\_lo\_Geyer](https://www.ruby-forum.com/u/PaSSS_lo_Geyer)\
**Post date:** [March 31, 2007, 2:19pm UTC](https://www.ruby-forum.com/t/database-migration/90720/1 "2007-03-31T14:19:13Z")

</div>

Hi, i’m migrating a web application from .NET (ASP+SQL Server) to  
Rails and MySQL, but i’m still learning how to access SQL Server  
database.

I’m writing a simple program using ActiveRecort (Stand Alone) to get  
the data from SQL Server and insert it into the new database, but i  
still couldn’t figure how to list SQL Server tables, here follows the  
actual code:  
#!/usr/bin/env ruby  
require ‘rubygems’  
require\_gem ‘activerecord’

ActiveRecord::Base.establish\_connection(  
:adapter =\> “sqlserver”,  
:host =\> “10.1.1.6”,  
:username =\> “sa”,  
:password =\> “\*\*\*”,  
:database =\> “jornaldedebates”  
)

class Artigo \< ActiveRecord::Base  
set\_table\_name “Artigo”  
end

artigo.find(:all).each {|artigo|  
puts artigo  
}

The SQL Server database “jornaldedebates” have an table called  
“dbo.artigos”, i still couldn’t get it, any ideas?

---

<div class="post-metadata">

**Author:** ![PaSSS\_lo\_Geyer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/eb9ed0/32.png) [@PaSSS\_lo\_Geyer](https://www.ruby-forum.com/u/PaSSS_lo_Geyer)\
**Post date:** [March 31, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/database-migration/90720/2 "2007-03-31T17:15:34Z")

</div>

PaÅ­lo Geyer wrote:

> Hi, i’m migrating a web application from .NET (ASP+SQL Server) to  
> Rails and MySQL, but i’m still learning how to access SQL Server  
> database.
> 
> class Artigo \< ActiveRecord::Base  
> set\_table\_name “Artigo”  
> end
> 
> artigo.find(:all).each {|artigo|  
> puts artigo  
> }
> 
> The SQL Server database “jornaldedebates” have an table called  
> “dbo.artigos”, i still couldn’t get it, any ideas?

Can you make connection to the database first?
