Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 non-dbo schema users read data from dbo objects

Author  Topic 

yangziyi
Starting Member

5 Posts

Posted - 2010-09-07 : 02:39:17
Have you guys met this problem before?
User A, default schema is 'Test';
The schema of table 'tableB' is dbo;
when access the db with user A and read data from table -- tableB using the following query 1)--
SELECT * FROM tableB

ranther than using query 2) --
SELECT * FROM dbo.tableB

the results can be got successfully.

My question is: if the default schema for user A is not dbo, then the schema name should be required, right? That's to say, the query 1) should mean like this: SELECT * FROM Test.tableB, right?

Is there anyone can help me out?
Really appreciate your help.

Thanks,
Ziyi

Ancy
Starting Member

23 Posts

Posted - 2010-09-07 : 04:59:28
Hi Ziyi,

What you are mentioning is true if the schema for the table is anything other than dbo. The "dbo" schema is the default schema and hence does not need to be mentioned.
Go to Top of Page

yangziyi
Starting Member

5 Posts

Posted - 2010-09-07 : 05:21:03
quote:
Originally posted by Ancy

Hi Ziyi,

What you are mentioning is true if the schema for the table is anything other than dbo. The "dbo" schema is the default schema and hence does not need to be mentioned.



Thank you Ancy for your response.
Base on your understanding of Schema, can u please give me an answer for the following situations:
User Name Default Schema Full Table Name
A SchemaA SchemaA.TableA

can the following query execute successfully?

For user A: SELECT * FROM tableA

Go to Top of Page

Ancy
Starting Member

23 Posts

Posted - 2010-09-07 : 05:32:26
No. The fully qualified name has to be provided if the schema name is anything other than dbo. The query should be
SELECT * FROM SchemaA.tableA
Go to Top of Page

yangziyi
Starting Member

5 Posts

Posted - 2010-09-07 : 05:48:01
quote:
Originally posted by Ancy

No. The fully qualified name has to be provided if the schema name is anything other than dbo. The query should be
SELECT * FROM SchemaA.tableA



Well, actually, it can got the right results. So....
You can have a try about this. :)

So... :(
Go to Top of Page

yangziyi
Starting Member

5 Posts

Posted - 2010-09-15 : 23:04:04
Is there anyone else to get me out here?
Go to Top of Page
   

- Advertisement -