Click here to Skip to main content
15,881,413 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
create table customer_Name(

Fname        varchar(20),
Minit        varchar(20),
Lname        varchar(20),
Customer_id    int,
constraint customer_name_pk
primary key (Customer_id),

);





Msg 1801, Level 16, State 3, Line 1
Database 'clothingstore' already exists. Choose a different database name.
Msg 2714, Level 16, State 6, Line 2
There is already an object named 'customer' in the database.


What I have tried:

NOte the table has run before but when I try to run it again this message appears
Posted
Updated 2-Dec-22 0:28am
Comments
Chris Copeland 2-Dec-22 6:12am    
So you've already created the table and you're trying to create it again? Why? Once you've created the table you can either alter it using alter table commands, or drop it completely using drop table commands (though this will erase all the data in the table)

1 solution

If a database exists on a particular server, you cannot create a new DB of the same name without deleting the existing one first - if you try, you get the first error.

The second error is exactly the same, but for the table of the same name.

Databases are designed to be persistent: they hold information even when your app is not running. If you app tries to create the DB and it's tables each time it starts, that persistence would go away, and the data would not be carried forward into you app each time it ran.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900