# Sqlserver views instead of tables

**URL:** <https://www.ruby-forum.com/t/sqlserver-views-instead-of-tables/149481>\
**Category:** Rails\
**Created:** [September 25, 2008, 8:48am UTC](https://www.ruby-forum.com/t/sqlserver-views-instead-of-tables/149481 "2008-09-25T08:48:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mfairchi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@mfairchi](https://www.ruby-forum.com/u/mfairchi)\
**Post date:** [September 25, 2008, 8:48am UTC](https://www.ruby-forum.com/t/sqlserver-views-instead-of-tables/149481/1 "2008-09-25T08:48:40Z")

</div>

Hello,  
I have a legacy database in sqlserver 2005 that I am not allowed to  
change. I have tried using a view, as I have read it works for  
others, however I get an error.

I have this in my model:

class SheetEntryView \< ActiveRecord::Base  
set\_table\_name ‘Sheet\_Entry\_View’  
set\_primary\_key ‘sheet\_entry\_KEY’  
end

When I go to the console and try  
-\>s=SheetEntryView  
-\>SheetEntryView (Table doesn’t exist)

I think part of the problem can be traced to this message in my log,  
SELECT TABLE\_NAME FROM INFORMATION\_SCHEMA.TABLES WHERE TABLE\_TYPE =  
‘BASE TABLE’

Is there something else I need to configure in activerecord to allow  
it to work with sqlserver views?

Thanks,  
Michael

---

<div class="post-metadata">

**Author:** ![mfairchi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/eb8c5e/32.png) [@mfairchi](https://www.ruby-forum.com/u/mfairchi)\
**Post date:** [September 28, 2008, 11:58am UTC](https://www.ruby-forum.com/t/sqlserver-views-instead-of-tables/149481/2 "2008-09-28T11:58:01Z")

</div>

I haven’t played around with it myself, but this might be a place to  
start:

[http://activewarehouse.rubyforge.org/rails\_sql\_views/](http://activewarehouse.rubyforge.org/rails_sql_views/)
