简体   繁体   English

Azure SQL Server BCP -

[英]Azure SQL Server BCP -

I have a csv file with 3 columns我有一个包含 3 列的 csv 文件

LastName
FirstName
EmpID

I was SQLLDR to load the data into Oracle database however I opted to use BCP to load the data into Azure sqlserver after the database migration to Azure SQL Server.我是 SQLLDR 将数据加载到 Oracle 数据库中,但是在数据库迁移到 Azure SQL Server 后,我选择使用 BCP 将数据加载到 Azure sqlserver。

I am using the following command to generate the format我正在使用以下命令生成格式

bcp Database.Schema.Persons format nul -c -t, -f Persons.fmt -S tcp:demo.database.windows.net -U User01 -PP@$$word! bcp Database.Schema.Persons 格式 nul -c -t, -f Persons.fmt -S tcp:demo.database.windows.net -U User01 -PP@$$word!

It has following format它有以下格式

13.0
3
1       SQLCHAR             0       255     ","      1     LastName               SQL_Latin1_General_CP1_CI_AS
2       SQLCHAR             0       255     ","   2     FirstName              SQL_Latin1_General_CP1_CI_AS
3       SQLINT             0       255     "\r\n"   3     FirstName              SQL_Latin1_General_CP1_CI_AS

However SQLLDR ctl file has the following functions但是SQLLDR ctl文件有以下功能

LPAD(:EmpID, 4, '0')
DATE "YYYY-MM-DD"
TIMESTAMP "YYYY-MM-DD-HH24.MI.SS.FF6"
NVL(:LastName, '')

How do I accommodate in the BCP format file?我如何适应 BCP 格式的文件?

How do I accommodate in the BCP format file?我如何适应 BCP 格式的文件?

You don't.你没有。 BCP into a staging table and INSERT ... SELECT to your final table to apply transformations. BCP 到临时表和 INSERT ... SELECT 到您的最终表以应用转换。 Or stage the data in Azure Blob Storage and use INSERT ... .SELECT .或者在 Azure Blob 存储中暂存数据并使用INSERT ... .SELECT 。 . . . . FROM OPENROWSET to load the data into your target table. FROM OPENROWSET将数据加载到目标表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM