Tony Trinh Duy Tung
Tony Trinh Duy Tung

Reputation: 41

I have changed default schema of a database from dbo to something else but when I wrote query it still took dbo as default schema

I have changed default schema of a database from dbo to something else but when I wrote query it still took dbo as default schema

I am using Microsoft SQL server 2008 and have some problems.Please help me on this:

I have a database which has two schemata, one is dbo and another one is studentlinkweb.

I was logging in as studentlinkweb. At first, the default schema is dbo, then I had already successfully set default schema from dbo to schema studentlinkweb for the login studentlinkweb. (I have already checked it under

database_name>Security>Users>properties(right click)> general and

under Database>Security>Logins>loginID>properties(right click)>User Mapping)

However, when I wrote SQL script it did not work as expected. to be specific:

I have a table names table_name under schema studentlinkweb.

When I wrote Select * from table_name and ran, it returned a message: Invalid object name 'table_name'

when I wrote Select * from studentlinkweb.table_name and ran, the query excecuted sucessfully.

I have another table names table_name2 under schema dbo,

When I wrote Select * from table_name2 and ran, the query excecuted sucessfully. . Here I didn't specify the schema but the query still ran successfully

This meant that the default schema was still dbo.

Could you please give me some idea or suggestion?

Upvotes: 1

Views: 653

Answers (1)

Tony Trinh Duy Tung
Tony Trinh Duy Tung

Reputation: 41

When the login is set as 'sysadmin', the default schema will be fixed as dbo and cannot be changed whatsoever.

Upvotes: 2

Related Questions