same name for table and view | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

same name for table and view

Is it OK to have a view with exactly the same name as a table in the same DB? lp john
John: No. At least I’ll try many times without exit. Luis
Precisly no. _________
Satya SKJ

Well, thats not strictly true. A view can have the same name as a table as long as it doesnt have the same owner. So if you had a table called Sales owned by dbo, you could create a view (with user1 as the owner) on dbo.Sales and called it Sales also. if a user was logged in as user1 and you then query the table/view, without fully qualifying the table name, he would select from the user1.Sales view. If he wanted to select from the Sales table, he would need to qualify the object name, and ‘select * from dbo.Sales’ Having said that, its quite confusing working with a design of this nature. I recommend you try to find another way (vwSales_user01, vwSales_user02 etc) would be my way of naming it)
Practically we’d faced lot of troubles being same name for a Table & View. _________
Satya SKJ

]]>