当我创建表并使用CSV文件导入数据时,默认归类名称为“ SQL_Latin1_General_CP1_CI_AS”。我只想在导入数据时将排序规则名称设置为“ Latin1_General_CI_AS”。导入数据本身时,有什么可能的方法来配置它。
答案 0 :(得分:0)
使用Format File
到Bulk Import
数据。
例如Format File
:
\<?xml version="1.0"?>
\<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
\<FIELD ID="1" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="7"/>
\<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="25" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
\<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="," MAX_LENGTH="30" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
\<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="11"/>
</RECORD>
<ROW>
\<COLUMN SOURCE="1" NAME="PersonID" xsi:type="SQLSMALLINT"/>
\<COLUMN SOURCE="2" NAME="FirstName" xsi:type="SQLVARYCHAR"/>
\<COLUMN SOURCE="3" NAME="LastName" xsi:type="SQLVARYCHAR"/>
\<COLUMN SOURCE="4" NAME="BirthDate" xsi:type="SQLDATE"/>
</ROW>
</BCPFORMAT>
接下来,例如bulk insert
:
BULK INSERT dbo.myTable
FROM 'D:\BCP\myFile.csv'
WITH (FORMATFILE = 'D:\BCP\myFileFormat.fmt');