Can’t see created tables in Object Explorer – Microsoft SQL Management Studio

Posted on

Can’t see created tables in Object Explorer – Microsoft SQL Management Studio – This article will take you through the common SQL errors that you might encounter while working with sql, sql-server,  tsql. The wrong arrangement of keywords will certainly cause an error, but wrongly arranged commands may also be an issue. SQL keyword errors occur when one of the words that the SQL query language reserves for its commands and clauses is misspelled. If the user wants to resolve all these reported errors, without finding the original one, what started as a simple typo, becomes a much bigger problem.

SQL Problem :

I am trying to create some tables within a database, however the tables are not appearing in my object explorer view.

my code is as follows:

use testDB

create table dbo.teacher (id varchar(5), name varchar(24));
insert into teacher values ('dm112', 'Magro, Deirdre');
insert into teacher values ('je232', 'Elkner, Jeff');
insert into teacher values ('cm147', 'Meyers, Chris');
insert into teacher values ('kr387', 'Reed, Kevin');

create table dbo.course (
    number varchar(6),
    name varchar(24),
    credits int,
    teacherid varchar(6) 
insert into course values ('SDV100', 'College Success Skills', 1, 'dm112');
insert into course values ('ITD110', 'Web Page Design I', 3, 'je232');
insert into course values ('ITP100', 'Software Design', 3, 'je232');
insert into course values ('ITD132', 'Structured Query Language', 3, 'cm147');
insert into course values ('ITP140', 'Client Side Scripting', 4, 'kr378');
insert into course values ('ITP225', 'Web Scripting Languages', 4, 'kr387');

create table dbo.student (id varchar(3), name varchar(24));
insert into student values ('411', 'Perez, Gustavo');
insert into student values ('412', 'Rucker, Imani');
insert into student values ('413', 'Gonzalez, Alexis');
insert into student values ('414', 'Melgar, Lidia');

create table dbo.enrolled (studentId varchar(3), courseNumber varchar(6));
insert into enrolled values ('411', 'SDV100');
insert into enrolled values ('411', 'ITD132');
insert into enrolled values ('411', 'ITP140');
insert into enrolled values ('412', 'ITP100');
insert into enrolled values ('412', 'ITP14p');
insert into enrolled values ('412', 'ITP225');
insert into enrolled values ('413', 'ITD132');
insert into enrolled values ('413', 'ITP225');
insert into enrolled values ('414', 'SDV100');
insert into enrolled values ('414', 'ITD110');

I looked this up before posting and found this exact question:

Creating table with T-SQL – can’t see created tables in Object explorer

However, he was using “tempdb”, which I am not.

I ran the query

select name, type_desc from testDB.sys.objects

which returned:

name          type_desc
teacher       USER_TABLE
course        USER_TABLE 
student       USER_TABLE
enrolled      USER_TABLE

I can modify, select, drop, etc. on these tables, but I cannot see them. Am I missing something? Another question brought up the prospect of “test” and “production”? They didn’t go into much detail and google did not help me


Thank you for any help you can offer.

Edit: Karl below found the solution! Although clicking refresh (F5) on the object explorer does not update the database view, right clicking on the database and clicking refresh updates the tables.

Solution :

This would happen if you have the tables node open in object explorer and don’t refresh after running your DDL. It is annoying that SSMS doesn’t autorefresh explorer after DDL. Refresh is available via the right-click context menu in object explorer.

I had a scenario in which refreshing the folders in Object Explorer did not lead to my missing table appearing in either of the Tables or Views folders. Like the original post, I am able to query the table – but not find it in Object Explorer.

The Microsoft docs on the FROM clause specify that FROM is followed by table_source which is a qualified table_or_view_name which is defined as “Is the name of a table or view”. Yet while my FROM clause works, no such table or view name appears in Object Explorer (even after refresh). What’s going on here?

The original question had the following query:

select name, type_desc from testDB.sys.objects

which simplifies to:

select name, type_desc from sys.objects;

and this gave me the answer to my scenario, which differed from the original question.

In the original question the missing table’s type_desc value was USER_TABLE, but in my case it showed SYNONYM.

There is, in fact, another folder in Object Explorer for Synonyms – and this is where I found the “table” I was querying. (It would be helpful if Microsoft updated their doc to mention the fact that a Synonym name is also a valid value for use with the FROM clause – at least in my case, synonyms are not frequently used).

Try going to the SQL Server Object Explorer tab, and press that is located right of the refresh button —> Group By Object.

It was simply showing another Local database server for me..

I had to explicitly click on “Add SQL Server” (the icon beside refresh) and select the correct “MSSQLLocalDB” local Server.

This could be helpful if you are working on multiple projects.

I think you have to update table in DB. if you used visual studio you would easy do it. when you create table you can see button “update” in the left corner of window.
enter image description here

Finding SQL syntax errors can be complicated, but there are some tips on how to make it a bit easier. Using the aforementioned Error List helps in a great way. It allows the user to check for errors while still writing the project, and avoid later searching through thousands lines of code.

Leave a Reply

Your email address will not be published. Required fields are marked *