SQL Server bcp可以在带有Unix行尾的文件中吗? [英] Can SQL Server bcp in a file with Unix line endings?

查看:78
本文介绍了SQL Server bcp可以在带有Unix行尾的文件中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用SQL Server bcp实用程序从samba共享导入文本文件. bcp在Unix行结尾处令人窒息.我确定我可以在Unix或Windows上添加一个中间步骤,以将行尾更改为Windows样式.但是我更愿意不加修改地从Unix导入文件.

I'm trying to use the SQL Server bcp utility to import a text file from a samba share. bcp is choking on the Unix line endings. I'm sure I could add an intermediate step, either on Unix or Windows, to change the line endings to Windows-style. But I would prefer to import the files from Unix without modification.

有人知道是否有一种方法可以告诉SQL Server bcp查找Unix行结尾吗?

Anybody know if there's a way to tell SQL Server bcp to look for Unix line endings?

推荐答案

您必须使用带有bcp的格式文件,并将终止符指定为\ n.交互式命令行将始终附加\ r,其中格式文件将完全使用您指定的格式.参考 http://www .eggheadcafe.com/software/aspnet/32239836/bcp-out-with-char10-as-row-terminator.aspx .

You have to use a format file with bcp and specify the terminator as \n. The interactive command line will always append \r, where a format file will use exactly what you specify. Reference http://www.eggheadcafe.com/software/aspnet/32239836/bcp-out-with-char10-as-row-terminator.aspx.

在BOL中很好地解释了创建格式文件,但是如果需要帮助,请评论/更新您的原始帖子.

Creating a format file is explained pretty well in BOL but comment/update your original post if you need help.

这篇关于SQL Server bcp可以在带有Unix行尾的文件中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆