0

I am new to SQL and I am trying to run a CREATE TABLE query in Ms Access 2016 but I get an error saying that "mytablename" already exits which can't be true because I also ran a DROP TABLE "mytablename" query and I got an error saying "mytablename" does not exist. Please help. Point me in the right direction at least. Here is the CREATE TABLE query.

    CREATE TABLE Team(
    Team_ID AUTOINCREMENT UNIQUE NOT NULL,
    Name VARCHAR(40) NOT NULL,
    Origin VARCHAR(40) NOT NULL,
    NetWorth CURRENCY NOT NULL,
    PRIMARY KEY(Team_ID)
    );
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Apart from the table name being `Team` rather than `mytablename` - it works fine. I drop the table, run the query and it creates it. – Darren Bartrup-Cook Mar 03 '16 at 16:30
  • Are you specifying the database name (`use mydatabase`) in each session before attempting to create or test the existence of the table? – wallyk Mar 03 '16 at 17:27
  • I got it to work. I was not clicking Data Definition under the Design tab. Whenever I wanted to create a query I would simply click query design under the the create tab and then click SQL View on Query1 and type the commands. But this works on Ms Access 2013. I could create queries without having to click on Data Definition. I cant understand why it doesn't on Ms Access 2016. –  Mar 03 '16 at 19:27

1 Answers1

1

See check by VBA and check by SQL for check existence of your database.

If table exists you can recreate (drop and create again) table. Alternative way is to create table if table is not exist and do nothing if table exists.

Community
  • 1
  • 1