0

I'm new to SQL and have the follow problem:

I want 1 script where I create my database and its tables:

CREATE DATABASE TestDB;
USE TestDB
CREATE TABLE Customers
(
  CustomerID int NOT NULL,
  Company nvarchar(150) Not NULL,
  CONSTRAINT pk_CustomerID PRIMARY KEY (CustomerID)
);
// further tables with same scheme like 'Customers'

With this script, I always get the error: TestDB is not existing...

I use SQL Server Express 2008 and SQL Server Management Studio

Thanks for help!

GrayFox
  • 997
  • 1
  • 9
  • 26

1 Answers1

1

Try this:

   CREATE DATABASE TestDB;
   GO
   USE TestDB
   GO
    CREATE TABLE Customers
    (
      CustomerID int NOT NULL,
      Company nvarchar(150) Not NULL,
      CONSTRAINT pk_CustomerID PRIMARY KEY (CustomerID)
    );
    // further tables with same scheme like 'Customers'
Sparky
  • 14,967
  • 2
  • 31
  • 45