我正在尝试运行此批量导入查询,并且我一直收到相同的错误'''附近的错误语法''查询是:
BULK INSERT
[ Centra . [ dbo] .
[ InfoHeader ]
FROM 'C:\Share\092013-DB.txt'
[ WITH
(
[ [ , ] BATCHSIZE = 10000000 ]
[ [ , ] CHECK_CONSTRAINTS ]
[ [ , ] CODEPAGE = 'OEM' ]
[ [ , ] DATAFILETYPE = 'char']
[ [ , ] FIELDTERMINATOR = '\t' ]
[ [ , ] FIRSTROW = 1 ]
[ [ , ] FIRE_TRIGGERS ]
[ [ , ] KEEPIDENTITY ]
[ [ , ] KEEPNULLS ]
[ [ , ] KILOBYTES_PER_BATCH = kilobytes_per_batch ]
[ [ , ] LASTROW = 0 ]
[ [ , ] MAXERRORS = 100 ]
[ [ , ] ROWS_PER_BATCH = rows_per_batch ]
[ [ , ] ROWTERMINATOR = '\r\n' ]
[ [ , ] ERRORFILE = 'C:\bulkimportlog.txt' ]
)]
答案 0 :(得分:1)
[ WITH ... ]
语法表示WITH ...
可选。
方括号不是语法的一部分,它们用于表示语法的封闭部分可以省略。
您可以在此处的文档中查看所有符号的含义:Transact-SQL Syntax Conventions。
这是您编辑的SQL(未经测试):
BULK INSERT Centra.dbo.InfoHeader
FROM 'C:\Share\092013-DB.txt'
WITH
(
BATCHSIZE = 10000000,
CHECK_CONSTRAINTS,
CODEPAGE = 'OEM',
DATAFILETYPE = 'char',
FIELDTERMINATOR = '\t',
FIRSTROW = 1,
FIRE_TRIGGERS,
KEEPIDENTITY,
KEEPNULLS,
KILOBYTES_PER_BATCH = kilobytes_per_batch, -- need number here
LASTROW = 0,
MAXERRORS = 100,
ROWS_PER_BATCH = rows_per_batch, -- and here
ROWTERMINATOR = '\r\n',
ERRORFILE = 'C:\bulkimportlog.txt'
)
此外,由于大部分内容都是可选的,您可能不需要也不希望它们全部出现在语句中,如果您将它们保留为默认值,我宁愿将它们取出并使语句更容易阅读