Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6021335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:41:53+00:00 2026-05-23T03:41:53+00:00

We are having an issue with a Ruby on Rails 3.0.3 application. It seems

  • 0

We are having an issue with a Ruby on Rails 3.0.3 application. It seems that for some reason, ActiveRecord is using a query formatted for MySQL when we do a find() on an MSSQL model. The rails app is using MySQL for its models; however, also has reference models that are backed within an MSSQL database. As shown in the below message, we are using an ODBC connection. When I call Club.find(137) I get the following error:

ODBC::Error: 37000 (102) [unixODBC][FreeTDS][SQL Server]Incorrect syntax near ‘LIMIT’.: SELECT [club].* FROM [club] WHERE ([club].[ClubID] = N’137′) LIMIT 1

Note that Club.find(:all) works fine so connectivity is working, the problem lies in the generation of the SQL query format. OtherModel.find(1) also works (the model that is connected to the MySQL database).

Is what I’m doing impossible? I’m assuming its something with the caching of queries… Does anyone know how to resolve the above? Thanks so much for all the help in advance.

Here is the setup:

Gems:
gem ‘mysql2’
gem ‘rails-dbi’
gem ‘ruby-odbc’
gem ‘activerecord-sqlserver-adapter’

Models (examples):

class Club < External
...
end

class External < ActiveRecord:Base
  establish_connection('mssql_' + Rails.env)
...
end

class OtherModel < ActiveRecord:Base
...
end

database.yml Example:

environment:
  adapter: mysql2
  encoding: utf8
  host: localhost
  pool: 5
  username: 
  password: 
  database: my_app_development

mssql_environment:
  adapter: sqlserver
  mode: odbc
  pool: 5
  dsn: MYDSN
  username: 
  password: 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:41:53+00:00Added an answer on May 23, 2026 at 3:41 am

    I am the author for the adapter and some things we have in the Arel visitor for SQL Server has to extend the visitors for limit/offset. I think this was a bug we have fixed in the latest versions so those working with the SQL Server adapter in a multi-db environment have a better experience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ruby 1.9 rails 3.0.7 application that is using lucid/solr to index
I'm having an issue integrating flex with ruby on rails. I get this error:
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I am currently having a strange issue with an application migrated from rails 2.3.8
I'm having an issue with Lucene's Term [Boosting][1] query syntax, specifically in Ruby on
I am having an Issue with Formastic and Ruby On Rails Here is the
I'm having a stack level too deep error using Ruby 1.8.7 with Rails 3.0.4
Javan's Whenever gem for Ruby on Rails is fantastic, however, I'm having one issue
I'm still new to Ruby on Rails and I'm currently having a issue with
Having an issue here that I have tried everything I can think of but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.