# Instiki and SQL Server?

**URL:** <https://www.ruby-forum.com/t/instiki-and-sql-server/54378>\
**Category:** Rails\
**Created:** [March 2, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378 "2006-03-02T22:08:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 2, 2006, 10:08pm UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/1 "2006-03-02T22:08:22Z")

</div>

Hello. I reeeeally want to get Instiki running at my day job, but they  
are Microsoft-heads. While I can probably sell them on trying Rails,  
they are definitely going to want the database to sit in our SQL Server  
instance with our other databases. I can’t get instiki to create the  
tables in sql server though (I’ve added ADO.rb, and gotten a  
connection). When I run the create\_db script I get the output below.  
Has anyone tried this?

C:\software\instiki-ar\>ruby script/create\_db  
C:/software/instiki-ar/script/…/config/environment.rb:16: warning:  
already init  
ialized constant RAILS\_ROOT  
C:/software/instiki-ar/script/…/config/environment.rb:23: warning:  
already init  
ialized constant RAILS\_ENV  
C:/software/instiki-ar/script/…/config/environment.rb:26: warning:  
already init  
ialized constant ADDITIONAL\_LOAD\_PATHS  
C:/software/instiki-ar/script/…/config/environment.rb:73: warning:  
already init  
ialized constant RAILS\_DEFAULT\_LOGGER  
C:/software/instiki-ar/script/…/config/environment.rb:90: warning:  
already init  
ialized constant Controllers  
Creating tables for production…  
failed: #\<RuntimeError: Unknown db type sqlserver\>  
C:/software/instiki-ar/script/…/config/environment.rb:16: warning:  
already init  
ialized constant RAILS\_ROOT  
C:/software/instiki-ar/script/…/config/environment.rb:23: warning:  
already init  
ialized constant RAILS\_ENV  
C:/software/instiki-ar/script/…/config/environment.rb:26: warning:  
already init  
ialized constant ADDITIONAL\_LOAD\_PATHS  
C:/software/instiki-ar/script/…/config/environment.rb:73: warning:  
already init  
ialized constant RAILS\_DEFAULT\_LOGGER  
C:/software/instiki-ar/script/…/config/environment.rb:90: warning:  
already init  
ialized constant Controllers  
Creating tables for test…  
failed: #\<RuntimeError: Unknown db type sqlserver\>  
C:/software/instiki-ar/script/…/config/environment.rb:16: warning:  
already init  
ialized constant RAILS\_ROOT  
C:/software/instiki-ar/script/…/config/environment.rb:23: warning:  
already init  
ialized constant RAILS\_ENV  
C:/software/instiki-ar/script/…/config/environment.rb:26: warning:  
already init  
ialized constant ADDITIONAL\_LOAD\_PATHS  
C:/software/instiki-ar/script/…/config/environment.rb:73: warning:  
already init  
ialized constant RAILS\_DEFAULT\_LOGGER  
C:/software/instiki-ar/script/…/config/environment.rb:90: warning:  
already init  
ialized constant Controllers  
Creating tables for development…  
failed: #\<RuntimeError: Unknown db type sqlserver\>

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 3, 2006, 2:06am UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/2 "2006-03-03T02:06:41Z")

</div>

Hi Brian,

Have never tried this, but…

> Creating tables for development…  
> failed: #\<RuntimeError: Unknown db type sqlserver\>

The above error means Rails couldn’t connect to the DB. I assume you  
already read:  
[http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServer](http://wiki.rubyonrails.com/rails/pages/HowtoConnectToMicrosoftSQLServer)

What’s left is to make sure that the ADO.rb file is loaded correctly -  
probably in the config/environment.rb file BEFORE the Initializer.run  
call.

HTH,  
Assaph

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 3, 2006, 2:50am UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/3 "2006-03-03T02:50:28Z")

</div>

Thanks Assaph,

The interesting thing is that when I run instiki and hit it with a  
browser, it seems like it is connecting to the db, just not finding the  
tables because I can’t get the create\_db to run:

Execute  
OLE error code:80040E37 in Microsoft OLE DB Provider for SQL Server  
Invalid object name ‘webs’.  
HRESULT error code:0x80020009  
Exception occurred.: SELECT COUNT(\*) FROM webs

/app/models/wiki.rb:82:in `setup?' /app/controllers/wiki_controller.rb:17:in`index’  
./script/server:49  
instiki:6:in `load’  
instiki:6

But, I just added:  
ActiveRecord::Base.connection.instance\_variable\_get("@connection")[“AutoCommit”]  
= false

to the bottom of my environment.rb per the How-To page, but no change.  
Is there another change I should make in the environment.rb that you are  
referring to?

Thanks,

Brian

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 3, 2006, 3:49am UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/4 "2006-03-03T03:49:12Z")

</div>

> The interesting thing is that when I run instiki and hit it with a  
> browser, it seems like it is connecting to the db, just not finding the  
> tables because I can’t get the create\_db to run:

Oops my bad - just remembered setup in the ARbeta. You have three  
options:

1. Muck about with lib/db\_structure.rb to add handling of MSSQL specific  
types
2. Translate the PostgreSQL schema
3. Use the latest SVN sources. There all you need to do is define the  
connection  
in database.yml and run ‘rake migrate’.

I believe option 3 is easiest 😉

Cheers,  
Assaph

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 3, 2006, 3:55am UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/5 "2006-03-03T03:55:33Z")

</div>

Assaph M. wrote:

> I believe option 3 is easiest 😉

I agree! I will try this asap. Thanks for all your help!

---

<div class="post-metadata">

**Author:** ![madscene](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/5f9b8f/32.png) [@madscene](https://www.ruby-forum.com/u/madscene)\
**Post date:** [March 3, 2006, 4:19am UTC](https://www.ruby-forum.com/t/instiki-and-sql-server/54378/6 "2006-03-03T04:19:06Z")

</div>

Brian D. wrote:

> Assaph M. wrote:
> 
> > I believe option 3 is easiest 😉

Worked like a charm! Thanks again!!
