The Sales Database Sample Script
CREATE DATABASE Sales_v1
GO
USE Sales_v1
GO
CREATE TABLE [Customers](
[CustomerID] [int] NOT NULL CONSTRAINT [PK_Customers_CustomerID]
PRIMARY KEY CLUSTERED,
[AccountID] [nvarchar](15) NOT NULL,
[Title] [nvarchar](8) NULL,
[FirstName] [nvarchar](30) NOT NULL,
[MiddleName] [nvarchar](30) NULL,
[LastName] [nvarchar](30) NOT NULL,
[Suffix] [nvarchar](10) NULL,
[Address] [nvarchar](200) NULL,
)
GO
INSERT INTO [Sales_v1].[dbo].[Customers]
([CustomerID],
[AccountID],
[Title],
[FirstName],
[MiddleName],
[LastName],
[Suffix],
[Address])
VALUES
(1,
'ACC-1',
'Mr',
'Thomas',
'James',
'Smith',
'',
'')
GO
CREATE DATABASE Sales_v2
GO
USE Sales_v2
GO
CREATE TABLE [Customers](
[CustomerID] [int] NOT NULL CONSTRAINT [PK_Customers_CustomerID]
PRIMARY KEY CLUSTERED,
[AccountID] [nvarchar](15) NOT NULL,
[Title] [nvarchar](8) NULL,
[FirstName] [nvarchar](30) NOT NULL,
[MiddleName] [nvarchar](30) NULL,
[LastName] [nvarchar](30) NOT NULL,
[Suffix] [nvarchar](10) NULL,
[Address] [nvarchar](200) NULL,
)
GO
CREATE TABLE [Accounts](
[AccountID] [nvarchar](15) NOT NULL CONSTRAINT [PK_Accounts_AccountID]
PRIMARY KEY CLUSTERED,
[Status] [int] NOT NULL,
[Services] [nvarchar](200) NULL
)
GO
INSERT INTO [Sales_v2].[dbo].[Accounts]
([AccountID],
[Status],
[Services]
)
VALUES (N'90128',
0,
N'Confections')
GO
ALTER TABLE [Customers] ADD
CONSTRAINT [FK_Customers_Accounts_AccountID] FOREIGN KEY
(
[AccountID]
) REFERENCES [Accounts](
[AccountID]
)
GO