문제

I have a view in SQL Server, lets say MY_VIEW.

When I execute the command SELECT * FROM MY_VIEW it works fine. However, when I execute it as SELECT * FROM dbo.MY_VIEW I get *Invalid object name 'MyDB.dbo.MY_VIEW'*

I am connected to SQL server using sa.

What is wrong with this? And when should we use dbo.MY_VIEW and when not?

Update: The schema name on the view is dbo and when I created the view then too I had connected with sa.

Update2 I found the problem was case sensitive collation. The problem was not because of the dbo. prefix. It was because the database collation was case sensitive and table names in queries were in wrong case.

도움이 되었습니까?

해결책 3

I found the problem was case sensitive collation. The problem was not because of the dbo. prefix. It was because the database collation was case sensitive and table names in queries were in wrong case.

다른 팁

Did you create your objects under a different schema name than dbo? It would depend on the default schema name for your user account if you didn't qualify it when you created the view. In SQL 2k5 and 2k8 I believe the default behavior is to create a new schema for each user vs. assigning them to the 'dbo' schema.

You are in the master database. You created the view in the master database. Your actual query was SELECT * FROM MyDB.dbo.MY_VIEW. Try creating the view in the MyDB database instead.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top