# Activerecord mssql adapter - Auto ID support

**URL:** <https://www.ruby-forum.com/t/activerecord-mssql-adapter-auto-id-support/180976>\
**Category:** IronRuby\
**Created:** [January 2, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/activerecord-mssql-adapter-auto-id-support/180976 "2010-01-02T18:14:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 2, 2010, 6:14pm UTC](https://www.ruby-forum.com/t/activerecord-mssql-adapter-auto-id-support/180976/1 "2010-01-02T18:14:19Z")

</div>

Hello,

Just playing around with ActiveRecord, IR and Sql Server and it seems  
that it executes scope\_identity() as a separate statement, instead of  
being part of the batch file. As such, the object is never being  
updated correctly.

SQL Profiler shows this:

SQL:BatchStarting INSERT INTO [users] ([name], [email])  
VALUES(‘JimBob’, ‘removed\_email\_address@domain.invalid’) Mono local 57  
2010-01-02  
17:01:32.640  
SQL:BatchStarting exec sp\_executesql N’SELECT scope\_identity()’  
Mono local 57 2010-01-02 17:01:32.657

Any ideas? Anyone got this working?

Thanks

Ben
