来自文件的BULK INSERT具有额外值

时间:2015-07-02 16:43:40

标签: sql-server bcp

如何告诉格式文件应忽略csv文件中的列。我尝试输入0,我得到无效的列号错误:

Format file: 

10.0
9
0      SQLCHAR             0       12      "\t"     1     ID                   ""
2      SQLCHAR             0       10      "\t"     2     Symbol               SQL_Latin1_General_CP1_CI_AS
0      SQLCHAR             0       11      "\t"     3     DateDone             ""
0      SQLCHAR             0       19      "\t"     4     TimeDone             ""
4      SQLCHAR             0       10      "\t"     5     Side                 SQL_Latin1_General_CP1_CI_AS
5      SQLCHAR             0       12      "\t"     6     Size                 ""
6      SQLCHAR             0       41      "\t"     7     Price                ""
7      SQLCHAR             0       10      "\t"     8     Exchange             SQL_Latin1_General_CP1_CI_AS
8      SQLCHAR             0       12      "\r\n"   9     Position             ""

csv数据的示例行

------------------------------------------------------------------------------------------------------------------------
|AccountName || ExecSymbol ||   ExecDateTime || ExecSide    || ExecSize || ExecPrice    || ExecExchange || PositionSize|
 ------        ------------  ----------------  ------------  -----------   ----------      -------------   -------------
    PRIMU$    ||   SCO      ||    1/2/2013    ||   B         ||  100     ||  38.87       ||   ARCA       ||   100

1 个答案:

答案 0 :(得分:1)

最简单的方法是创建一个' fmt'可以指定要导入的内容以及要忽略的内容的文件:

https://msdn.microsoft.com/en-us/library/ms179250.aspx