Search code examples
sqlsql-serverdatabasesql-server-2012qsqltablemodel

Table is still exist after dropping it and the whole database too


I get this message after I dropped the table and the database completely

Msg 2714, Level 16, State 6, Line 12
There is already an object named 'Users' in the database

I tried to create and drop the same database but no use.

I also dropped the same table but when I want to create it, it shows the same error again.

I'll be glad for any help

 CREATE DATABASE Music
 GO

 CREATE TABLE [Users](
 [User_ID] int NOT NULL identity (1,1) Primary key,
 [UserName] nvarchar (30) NOT NULL,
 [UserEmail] nvarchar (30) NOT NULL,
 [Password] nvarchar (30) NOT NULL
 )
 GO

Solution

  • CREATE DATABASE Music GO
    
    USE [Music]
    GO
    
    CREATE TABLE [Users]( [User_ID] int NOT NULL identity (1,1) Primary key, [UserName] 
    nvarchar (30) NOT NULL, [UserEmail] nvarchar (30) NOT NULL, [Password] nvarchar (30) NOT NULL ) GO
    

    you are creating the table in the database where you have the initial query to. See above to first switch to the new DB...