Используйте следующий код, чтобы создать таблицу Prospect, используемую в этом руководстве.
if not exists (select *
from dbo.sysobjects where id = object_id(N'[dbo].[Prospect]') and
OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [Prospect] (
[ProspectKey] [int] IDENTITY (1, 1) NOT NULL ,
[GeographyKey] [int] NULL ,
[ProspectAlternateKey] [nvarchar] (15) NOT NULL ,
[Salutation] [nvarchar] (8) NULL ,
[FirstName] [nvarchar] (50) NULL ,
[MiddleName] [nvarchar] (50) NULL ,
[LastName] [nvarchar] (50) NULL ,
[NameStyle] [bit] NULL ,
[BirthDate] [datetime] NULL ,
[MaritalStatus] [nchar] (1) NULL ,
[Suffix] [nvarchar] (10) NULL ,
[Gender] [nvarchar] (1) NULL ,
[EmailAddress] [nvarchar] (50) NULL ,
[YearlyIncome] [money] NULL ,
[TotalChildren] [tinyint] NULL ,
[NumberChildrenAtHome] [tinyint] NULL ,
[Education] [nvarchar] (40) NULL ,
[Occupation] [nvarchar] (100) NULL ,
[HouseOwnerFlag] [nchar] (1) NULL ,
[NumberCarsOwned] [tinyint] NULL ,
[AddressLine1] [nvarchar] (120) NULL ,
[AddressLine2] [nvarchar] (120) NULL ,
[Phone] [nvarchar] (20) NULL ,
[DateFirstPurchase] [datetime] NULL ,
CONSTRAINT [PK_Prospect_ProspectKey] PRIMARY KEY CLUSTERED
(
[ProspectKey]
) ON [PRIMARY] ,
CONSTRAINT [AK_Prospect_ProspectAlternateKey] UNIQUE NONCLUSTERED
(
[ProspectAlternateKey]
) ON [PRIMARY] ,
CONSTRAINT [FK_Prospect_DimGeography] FOREIGN KEY
(
[GeographyKey]
) REFERENCES
[DimGeography] (
[GeographyKey]
)
) ON [PRIMARY]
END
delete from Prospect
go
DECLARE @data_path NVARCHAR(520),
@DatabaseName NVARCHAR(100)
SET @data_path = 'c:\temp\'
SET @DatabaseName = 'AdventureWorksDW'
EXECUTE (N'BULK INSERT ' + @DatabaseName
+ '..Prospect FROM ''' + @data_path + N'\Prospect.csv''
WITH (
CODEPAGE=''ACP'',
DATAFILETYPE = ''char'',
FIRSTROW = 1,
FIELDTERMINATOR= ''\t'',
ROWTERMINATOR = ''\n'' ,
KEEPIDENTITY,
TABLOCK
)')