我有CSV格式以下數據文件 - https://www.dropbox.com/s/23dtr31pje15baz/yellow-dentist-chicago%2C%20il.csv?dl=0批量插入到SQL Server中的一個格式文件使用文本限定符
幾行有其用引號括起來的數據表明,中逗號數據是數據的一部分,而不是分隔符(請參閱第一個示例中第五行的「Bruce C. Gronner,DDS」)。因此,我的理解是,我需要使用此post中討論的格式文件。
作爲一個開始,我想出了這個
11.0
13
1 SQLCHAR 0 1000 "\"," 1 Name SQL_Latin1_General_CP1_CI_AS
2 SQLCHAR 0 1000 "\"," 2 Address SQL_Latin1_General_CP1_CI_AS
3 SQLCHAR 0 1000 "\"," 3 State SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 1000 "\"," 4 Phone SQL_Latin1_General_CP1_CI_AS
5 SQLCHAR 0 1000 "\"," 5 Rating SQL_Latin1_General_CP1_CI_AS
6 SQLCHAR 0 1000 "\"," 6 Reviews SQL_Latin1_General_CP1_CI_AS
7 SQLCHAR 0 1000 "\"," 7 Website SQL_Latin1_General_CP1_CI_AS
8 SQLCHAR 0 1000 "\"," 8 Email1 SQL_Latin1_General_CP1_CI_AS
9 SQLCHAR 0 1000 "\"," 9 MerchantVerified SQL_Latin1_General_CP1_CI_AS
10 SQLCHAR 0 1000 "\"," 10 Lat SQL_Latin1_General_CP1_CI_AS
12 SQLCHAR 0 1000 "\"," 11 Long SQL_Latin1_General_CP1_CI_AS
12 SQLCHAR 0 1000 "\"," 12 ListingURL SQL_Latin1_General_CP1_CI_AS
13 SQLCHAR 0 1000 "\r\n" 13 Email2 SQL_Latin1_General_CP1_CI_AS
然後我嘗試使用下面的SQL代碼導入
BULK INSERT RawData
FROM 'C:\Users\William\Dropbox\yellow-dentist-chicago, il'
WITH
(
FIRSTROW = 2,
FORMATFILE='C:\Users\William\Dropbox\formatfile.fmt'
);
我遇到的主要問題是,只有一個數據的小子集用引號括起來(只有當數據中有逗號時),所以我不知道如何在格式文件中適當地格式化定界符模式列。任何幫助,將不勝感激。