Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command(s) completed successfully but... the tables are not created

I backed up my database table's and entire schema into .sql script using Visual Studio's Database Publishing Wizard.

I then tried to re-create those tables on another PC, not before re-creating the database itself, with the same exact name and everything (using a script that I created via SSMS's Script Database as).

I then open that tables .sql file using SSMS and execute it.

SSMS reports:

Command(s) completed successfully

But examining Object Explorer reveals that no tables were created.

Why is this happening?

What have I missed?

like image 692
Souper Avatar asked Oct 18 '12 17:10

Souper


People also ask

Why are my tables not showing in SQL?

For those using SQL Server Management Studio 2016 you simply need to hit 'F5' or go to 'View > Refresh' and your recently added tables should appear.

How do you check table is created or not?

To check if a table exists in SQL Server, you can use the INFORMATION_SCHEMA. TABLES table. You can use this table with an IF THEN clause do determine how your query responds whether or not a table exists. One of the more common uses I find for this when I need to create a table in a script.

How do I enable auto complete in SSMS?

How to Enable IntelliSense Feature in SSMS. Open SSMS, click Tools -> Options -> Expand Text Editor -> Expand Transact-SQL and click on IntelliSense as shown in the snippet below. Under Transact-SQL IntelliSense Settings ensure “Enable IntelliSense” checkbox is enabled.


1 Answers

I've just been having the exact same problem symptoms also using Visual Studio's Database Publishing Wizard, - but with a slightly different cause / fix.

Even though SQL Server Management Studio says it is connected to the correct database (in the drop down in the ribbon, and in the status bar of the window), it wasn't actually connected to anything.

To identify and fix either:

SELECT DB_NAME() AS DataBaseName

If you get

master

(or any other unexpected database name) as the result, then you are connected to the wrong database and should select the correct DB from the dropdown. This was the cause of your problem.

If you get

Command(s) completed successfully

then somehow you aren't connected at all - this happened to me.

To fix, click the "change connection" button to disconnect and reconnect.

like image 110
perfectionist Avatar answered Oct 03 '22 16:10

perfectionist