DEV.co
Open-Source Databases · rails-sqlserver

activerecord-sqlserver-adapter

activerecord-sqlserver-adapter is a Ruby gem that enables Rails applications to use Microsoft SQL Server as their database. It translates Rails' ActiveRecord ORM calls into SQL Server-compatible queries, supporting SQL Server 2012 and later with proper handling of SQL Server-specific features like identity inserts and stored procedures.

Source: GitHub — github.com/rails-sqlserver/activerecord-sqlserver-adapter
982
GitHub stars
556
Forks
Ruby
Primary language
MIT
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryrails-sqlserver/activerecord-sqlserver-adapter
Ownerrails-sqlserver
Primary languageRuby
LicenseMIT — OSI-approved
Stars982
Forks556
Open issues22
Latest releaseUnknown
Last updated2026-07-04
Sourcehttps://github.com/rails-sqlserver/activerecord-sqlserver-adapter

What activerecord-sqlserver-adapter is

The adapter implements Rails' AbstractAdapter interface for SQL Server connectivity via TinyTDS and FreeTDS. It supports native SQL Server data types (datetime2, datetimeoffset, time with TDS 7.3+), OUTPUT INSERTED queries for identity retrieval, stored procedure execution, SHOWPLAN explain support, and schema management. Versioning tracks Rails majors (adapter 8.x for Rails 8.x).

Quickstart

Get the activerecord-sqlserver-adapter source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/rails-sqlserver/activerecord-sqlserver-adapter.gitcd activerecord-sqlserver-adapter# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Existing SQL Server Deployments

Organizations with legacy or standardized SQL Server infrastructure can maintain Rails applications without database migration or additional licensing complexity.

Enterprise Rails Projects

Large teams requiring SQL Server-specific features (stored procedures, schemas, identity inserts with triggers, SHOWPLAN analysis) benefit from first-class adapter support.

Greenfield Rails + SQL Server

New projects choosing SQL Server for compliance, tooling, or infrastructure reasons can leverage Rails' ORM with full data type support and migration capabilities.

Implementation considerations

  • Rails version must match adapter version exactly (e.g., adapter 8.1.x requires Rails 8.1.x); patch versions do not auto-cross-upgrade.
  • TinyTDS and FreeTDS 1.0+ are required; TDS version 7.3 must be explicitly set or defaulted for advanced data types (datetime2, datetimeoffset, time).
  • Tables with triggers require explicit adapter configuration (exclude_output_inserted_table_names) to use temporary table workaround instead of simple OUTPUT INSERTED.
  • SQL Server schema and user setup may require table_name_prefix configuration (e.g., 'dbo.') depending on permissions and schema naming.
  • Stored procedure execution requires custom model methods; no built-in Rails convention support, requiring manual SQL knowledge.

When to avoid it — and what to weigh

  • PostgreSQL/MySQL Standardization — If your organization standardizes on open-source databases, SQL Server adds licensing and tooling complexity; consider postgres or mysql adapters instead.
  • No SQL Server Infrastructure — Setting up SQL Server solely to use Rails is not cost-effective compared to native-supported databases; adds operational overhead without strategic benefit.
  • Cross-Database Portability Required — Applications needing to run on multiple databases will face SQL Server-specific code (triggers, OUTPUT INSERTED workarounds, schema reflection) that complicates portability.
  • Minimal Support Budget — SQL Server licensing, TinyTDS/FreeTDS dependency complexity, and smaller community (vs. PostgreSQL) mean less readily available support and slower issue resolution.

License & commercial use

MIT License. Permissive open-source license allowing commercial use, modification, and redistribution with attribution and warranty disclaimer. No additional restrictions on commercial deployment.

MIT License permits unrestricted commercial use. However, SQL Server itself (the database engine) requires licensing from Microsoft unless using Express Edition (limited to 10 GB and 1 CPU core); verify your SQL Server licensing separately. The adapter code carries no commercial restrictions.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityModerate
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No security vulnerabilities or posture details provided in available data. Standard ActiveRecord SQL injection protections apply (parameterized queries via adapter). Dependent on TinyTDS/FreeTDS security updates; monitor those libraries. SQL Server authentication (Windows vs. SQL Auth) and connection encryption (appname, TLS) are configurable but not enforced by default; review your database.yml and configure_connection patterns for compliance needs.

Alternatives to consider

PostgreSQL with activerecord-postgresql-adapter

Native Rails support, open-source, lower licensing cost, wider ecosystem, better cross-platform portability, and larger community. Choose if SQL Server is not a hard requirement.

MySQL/MariaDB with activerecord-mysql2-adapter

Open-source, ubiquitous hosting, simple setup, lower operational overhead than SQL Server. Trade-off: fewer enterprise features (no native window functions, less mature stored procedure tooling).

Direct ODBC/TDS clients without Rails ORM

For applications requiring deep SQL Server-specific features or performance tuning beyond ORM abstraction, raw SQL via gems like sequel or arel may offer more control but sacrifice Rails conventions.

Software development agency

Build on activerecord-sqlserver-adapter with DEV.co software developers

Assess whether SQL Server aligns with your infrastructure and licensing model. Review TinyTDS/FreeTDS dependencies and version compatibility with your target Rails release before committing.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

activerecord-sqlserver-adapter FAQ

What Rails versions are supported?
Adapter 8.1.x (active), 8.0.x (active), and unreleased 8.2.x (in development). Versions 7.2.x and below are end-of-life. Each adapter major version tracks exactly one Rails major version.
Do I need a separate SQL Server license to use this adapter?
The adapter itself is free (MIT). However, SQL Server (the database engine) requires licensing from Microsoft unless you use the free Express Edition, which has 10 GB storage and 1 CPU core limits.
What data types are supported?
All Rails simplified types map to SQL Server national (unicode) types. Advanced types (datetime2, datetimeoffset, time) require TDS version 7.3; see NATIVE_DATABASE_TYPES constant for complete list.
How do I handle tables with triggers?
Declare them in exclude_output_inserted_table_names with their primary key data type. The adapter will use a temporary table workaround instead of OUTPUT INSERTED to avoid trigger conflicts.

Software developers & web developers for hire

From first prototype to production, DEV.co delivers software development services around tools like activerecord-sqlserver-adapter. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source databases and beyond.

Evaluate SQL Server for Your Rails Stack

Assess whether SQL Server aligns with your infrastructure and licensing model. Review TinyTDS/FreeTDS dependencies and version compatibility with your target Rails release before committing.