SQLCMD:我们可以在输出文件中加上双引号吗? [英] SQLCMD : Can we put double quotation mark to output file ?

查看:31
本文介绍了SQLCMD:我们可以在输出文件中加上双引号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请问有什么办法可以在SQLCMD、SQL Server 2016导出的输出文件的每一列加上双引号",如下所示?

May I ask is there any way to put double quotation mark "" to each columns of the output file exported by SQLCMD, SQL Server 2016 as follows?

ex.
"TEST1", "TEST2", "TEST3"
"TEST1", "TEST2", "TEST3"

我们想通过 S3 存储桶为 AWS Redshift 导出文件.

We'd like to export files for AWS Redshift through S3 bucket.

如果 SQLCMD 上没有合适的选项,也许我们最好验证 Invoke-Sqlcmd、PowerShell.如果您有更好更简单的方法,您的任何建议都会被采纳.

If there is no approptiate options on SQLCMD, maybe we'd better to verify Invoke-Sqlcmd, PowerShell. If you have more better and simple way, any of your advice would be appriciated.

谢谢.

推荐答案

仅供参考,最后我选择了 PowerShell 来解决这个问题.

Just F.Y.I., finally I chose PowerShell for this porpose.

Invoke-Sqlcmd -Query $StrQry -ServerInstance $StrSvrName -IgnoreProviderContext | Export-Csv -path $StrExpFile -Encoding UTF8

如我所料,每个输出文件列都用"双引号括起来.

Each output file columns are enclosed by "" double quotations as my expectations.

输出文件包含额外的行,因此我在上传到 S3 存储桶时通过 AWS 复制命令选项IGNOREHEADER 2"跳过它们.

Output file includes extra lines so I skip them by AWS copy command options 'IGNOREHEADER 2', when uploading to S3 bucket.

谢谢.

这篇关于SQLCMD:我们可以在输出文件中加上双引号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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