我是SQL新手并遇到以下问题:
我需要一个脚本来创建我的数据库及其表:
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'
使用此脚本,我总是收到错误:TestDB不存在......
我使用SQL Server Express 2008和SQL Server Management Studio
感谢您的帮助!
答案 0 :(得分:1)
试试这个:
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'