# Problem with paging and MS SQL

**URL:** <https://www.ruby-forum.com/t/problem-with-paging-and-ms-sql/163288>\
**Category:** Rails\
**Created:** [March 18, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/problem-with-paging-and-ms-sql/163288 "2009-03-18T23:04:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![porcbelly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/a5b964/32.png) [@porcbelly](https://www.ruby-forum.com/u/porcbelly)\
**Post date:** [March 18, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/problem-with-paging-and-ms-sql/163288/1 "2009-03-18T23:04:45Z")

</div>

am trying to get the index page going on my table I am using a table  
on Micrsoft SQL Server, when showing a single row from the table it  
works OK. but when accessing the index I am gettingthe following  
error  
message

ActiveRecord::ActiveRecordError: Incorrect syntax near ‘.’.: SELECT  
\*  
FROM (SELECT TOP 15 \* FROM (SELECT TOP 15 sproclogs.\* FROM  
sproclogs ORDER BY sproclogs.[id] ASC) AS tmp1 ORDER BY sproclogs.  
  
[[id]] DESC) AS tmp2 ORDER BY sproclogs.[[id]] ASC

The trace that I am getting is:

:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/  
active\_record/connection\_adapters/abstract\_adapter.rb:188:in `log' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9/ lib/active_record/connection_adapters/jdbc_adapter.rb:581:in`execute’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9/  
lib/active\_record/connection\_adapters/jdbc\_adapter.rb:641:in `select' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-jdbc-adapter-0.9/ lib/active_record/connection_adapters/jdbc_adapter.rb:566:in`jdbc\_select\_all’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/  
active\_record/connection\_adapters/abstract/query\_cache.rb:60:in  
`select_all_with_query_cache' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/connection_adapters/abstract/query_cache.rb:81:in`cache\_sql’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/  
active\_record/connection\_adapters/abstract/query\_cache.rb:60:in  
`select_all_with_query_cache' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/base.rb:635:in`find\_by\_sql’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/  
active\_record/base.rb:1490:in `find_every' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/base.rb:589:in`find’  
vendor/plugins/active\_scaffold/lib/active\_scaffold/finder.rb:175:in  
`find_page' vendor/plugins/active_scaffold/lib/paginator.rb:66:in`call’  
vendor/plugins/active\_scaffold/lib/paginator.rb:66:in `page' vendor/plugins/active_scaffold/lib/paginator.rb:93:in`call’  
vendor/plugins/active\_scaffold/lib/paginator.rb:93:in `items' vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb: 66:in`do\_list’  
vendor/plugins/active\_scaffold/lib/active\_scaffold/actions/list.rb:  
33:in `list' vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb: 8:in`index’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/base.rb:1253:in `perform_action' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/filters.rb:617:in`call\_filters’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/filters.rb:610:in `perform_action_with_filters' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/benchmarking.rb:68:in`perform\_action\_with\_benchmark’  
C:/jruby-1.1.6/lib/ruby/1.8/benchmark.rb:293:in `measure' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/benchmarking.rb:68:in`perform\_action\_with\_benchmark’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/rescue.rb:136:in `perform_action_with_rescue' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/caching/sql_cache.rb:13:in`perform\_action\_with\_caching’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/  
active\_record/connection\_adapters/abstract/query\_cache.rb:34:in  
`cache' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/ active_record/query_cache.rb:8:in`cache’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/caching/sql\_cache.rb:12:in  
`perform_action_with_caching' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/base.rb:524:in`process’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/filters.rb:606:in `process_with_filters' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/session_management.rb:134:in`process\_with\_session\_management\_support’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/base.rb:392:in `process' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:183:in`handle\_request’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/dispatcher.rb:110:in `dispatch_unlocked' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:123:in`dispatch’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/dispatcher.rb:122:in `dispatch' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/dispatcher.rb:132:in`dispatch\_cgi’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/  
action\_controller/dispatcher.rb:39:in `dispatch' C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/ webrick_server.rb:103:in`handle\_dispatch’  
C:/jruby-1.1.6/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/  
webrick\_server.rb:74:in `service' C:/jruby-1.1.6/lib/ruby/1.8/webrick/httpserver.rb:104:in`service’  
C:/jruby-1.1.6/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' C:/jruby-1.1.6/lib/ruby/1.8/webrick/server.rb:173:in`start\_thread’
