当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - Is it possible to replace a SQL table with a SQL view in an already created model in MVC 4?

问题描述:

I have recently inherited a mess from the developer who used to sit in this chair over a year ago. One of the many things he did is create nearly identical tables in many databases (such as having a Users table in each database that contains exactly the same information). I am attempting to eliminate all the manual work that is currently being done every time a new employee is hired by eliminating these duplicate tables.

I have created a SQL view that represents data exactly as the old table did. It pulls it's data from the master database, but all the tables I need (and this new view) are all on the same DB. There is no need for the application I am working with to modify the users table, so it only needs read access (so a view should be fine, right?).

Is there any way to simply replace the table in code with the new view? I would be happy to provide more information if needed.

网友答案:

if the created view has the same name and same columns as the original table, it will work without app modification. It is also possible to modify data throught this view (with some restrictions...), see https://msdn.microsoft.com/en-us/library/ms180800.aspx .

分享给朋友:
您可能感兴趣的文章:
随机阅读: