I created a table using the
create table
command but it does not show up in the object explorer. I have tried refreshing both the explorer and IntelliSense but it still does not show up. The table is present in the database I confirmed that by printing it out using the select
command.

- 2,330
- 4
- 30
- 50
-
2And you are expanding the correct database in the object explorer? Share the code you used to create the table, share the code you used to select from it, and share a screenshot of your object explorer. – dfundako Jun 18 '18 at 19:47
-
I just have a single database on my machine apart from the default ones – Tanmay Bhatnagar Jun 18 '18 at 19:50
-
2See how it says 'master' on the bottom right? Expand System databases, master, and look for your table. – dfundako Jun 18 '18 at 19:51
-
So how do I make a new table in my newly created database? – Tanmay Bhatnagar Jun 18 '18 at 19:52
-
2You should have done a `use DSTRAINING` before creating that table. ;) – LukStorms Jun 18 '18 at 19:52
1 Answers
It appears like you created your table in the system master
database instead of in your user defined database. There are a few things you can do:
At the top of your query, write
USE your_database_name
That will set your connection to run your query against a specific database.In SSMS, on the top left by default I think, there should be a white box with a dropdown arrow next to it. This is a list of all the databases in the instance you are currently connected to. Click yours, and run your table create.
Fully qualify your table name during the create as my_database_name.schema_here.table_name_here
Always look at the bottom of your SSMS window and confirm you are running queries in the correct instance (dev vs prod) and running them against the correct database.
USE database_name
GO
CREATE TABLE dbo.my_new_table (ID INT)
GO
or
CREATE TABLE database1.dbo.test_user_table (ID INT)
GO

- 8,022
- 3
- 18
- 34