简体   繁体   中英

How can I write queries without having to specify the schema name?

I can only get data like this format:

SELECT * FROM Abc.ACADEMY   

Where Abc is a username, ACADEMY is a table name, and ABC is also my schema name

What I want to be able to write this as:

SELECT * FROM ACADEMY

How can I achieve this?

If you set the user's default schema to [abc] (or whatever it actually is), you won't have to specify that schema name as part of the full table name anymore.

-- before 
SELECT * FROM abc.ACADEMY
GO

ALTER USER userName WITH DEFAULT_SCHEMA = abc
GO

-- after 
SELECT * FROM ACADEMY
GO

I solved it !!

Here is the solution:

Changing of Schema owner which has been set before as my user name to "dbo" solved my problem.

http://www.ufuktukenmez.com/wp-content/uploads/2013/07/Adsiz.png

Thank you for helping.

This is how I usually do it

Use ABC

select * from Academy

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM