Skip to content
Advertisement

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

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
GO

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.

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement