简体   繁体   English

将CSV从Linux导入Azure SQL Server

[英]Import CSV from Linux to Azure SQL Server

I have an Azure SQL Server database and a linux box. 我有一个Azure SQL Server数据库和一个Linux盒子。 I have a csv file on the linux machine that I want to import into SQL Server. 我要导入到SQL Server的Linux机器上有一个csv文件。 I have a table already created where I am going to import this file. 我已经创建了一个表,将在其中导入该文件。

Why does this command return an Unknown argument: -U ? 为什么此命令返回Unknown argument: -U

bcp table in ~/test.csv -U myUsername -S databaseServerName -d dbName -q -c -t

When I rearrange the arguments passed to bcp like below, it returns an Unknown argument: -S 当我重新排列传递给bcp的参数(如下所示)时,它将返回一个Unknown argument: -S

bcp table in ~/test.csv -S databaseServerName -d dbName -U myUsername -q -c -t

So contrary to the documentation: 因此与文档相反:

https://docs.microsoft.com/en-us/sql/tools/bcp-utility?redirectedfrom=MSDN&view=sql-server-2017#U https://docs.microsoft.com/zh-cn/sql/tools/bcp-utility?redirectedfrom=MSDN&view=sql-server-2017#U

I hit issues where bcp does not like spaces after the argument names. 我遇到了一些问题,其中bcp不喜欢参数名称后的空格。

https://granadacoder.wordpress.com/2009/12/22/bcp-export/ https://granadacoder.wordpress.com/2009/12/22/bcp-export/

quote from the article above: 引用以上文章:

// //

The other syntax sugar is that there is no space after the -S argument. 另一个语法糖是-S参数后没有空格。 As seen below 如下所示

-SMyServerName\\MyInstanceName -SMyServerName \\ MyInstanceName

bcp.exe "SELECT cast(LastName as char(50)) , cast(FirstName as char(50)) , cast(MiddleName as char(50)) , cast(Suffix as char(50)) FROM MyAdventureWorksDB.Person.Person ORDER BY NEWID()" queryout PeopleRock.txt -c -t -T -SMyServerName\\MyInstanceName bcp.exe“从MyAdventureWorksDB.Person.Person中选择SELECT cast(姓氏为char(50)),cast(姓氏为char(50)),cast(MiddleName为char(50)),cast(后缀为char(50)) ORDER BY NEWID()“查询出PeopleRock.txt -c -t -T -SMyServerName \\ MyInstanceName

also

https://www.easysoft.com/products/data_access/odbc-sql-server-driver/bulk-copy.html#importing-data-table https://www.easysoft.com/products/data_access/odbc-sql-server-driver/bulk-copy.html#importing-data-table

check your syntax sugar in linux (below example is from above easysoft link) 在Linux中检查语法糖(下面的示例来自于easysoft链接)

./bcp AdventureWorks.HumanResources.myTeam in ~/myTeam.csv \\ -f ~/myTeam.Fmt -U mydomain\\myuser -S mymachine\\sqlexpress ./bcp〜/ myTeam.csv中的AdventureWorks.HumanResources.myTeam \\ -f〜/ myTeam.Fmt -U mydomain \\ myuser -S mymachine \\ sqlexpress

Note the above has the dbname.schemaname.tablename (before the "in" word above) 请注意,上面具有dbname.schemaname.tablename(在上面的“ in”一词之前)

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

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