Solved

SQL Server sys.objects not showing Schemas

Posted on 2012-03-22
6
241 Views
Last Modified: 2012-06-27
Hi,

I was always under the impression that "select * from sys.objects" should return every object in the database, but I am finding it is only returning objects under the main dbo schema.  There are three other schemas in the database, which show up when you query sys.schemas, but they are just missing from the main objects list.  I have tried various INFORMATION_SCHEMA items (tables, procedures, views etc) too, but the same thing is happening.

I am logged in as a user with full access to all the schemas (has equivalent sa rights), so I don't think it's permissions.

What am I missing?  Presumably there must be a way to return every single object in the database, regardless of the schema? (this is for a report, so I need to include everything).

Many thanks!
0
Comment
Question by:itfocus
  • 3
  • 3
6 Comments
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 37752814
Sure sounds like a potential permissions issue.

If the object is schema-scoped, it should show up in sys.objects.

Does the login have actual server-level "sysadmin"authority?  If so, it's not a permissions issue, and something else is going on.
0
 

Author Comment

by:itfocus
ID: 37752945
I have just double-checked, and the user does indeed have sysadmin authority.  I added serveradmin authority as well, just to see if that made a difference.  I am now seeing the dbo and the sys objects, but again, not the custom-created ones.  I had a look at one of the schemas, to see if I had to set permissions to this user specifically, but it didn't make any difference.

I reran "select * from sys.schemas" but actually looking at it again, none of the custom schemas are listed here either.  all the db_*** ones are, but my user-created ones are not.  Am I just looking in the wrong place?
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 37753220
Yeah, make sure you're in the right db.

And that the other names aren't synonyms or some other name that would not be in that db's sys.objects table -- although the synonyms themselves should be in sys.objects I think.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 37753245
Maybe you created the other schemas in another db by accident?

Otherwise this just makes no sense.
0
 

Accepted Solution

by:
itfocus earned 0 total points
ID: 37809823
Hi,

All the schemas were on the right DB and everything; I think it may have been something weird in the setup of the database though (it's an old, test one).  I tried the same thing on a couple of others, and it works ok, so will just chalk it up to random weirdness and move on.

Thanks for the feedback though.
0
 

Author Closing Comment

by:itfocus
ID: 37822814
My own comment upon closing the question.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question