Search code examples
sql-serveramazon-s3sqlcmd

SQLCMD : Can we put double quotation mark to output file ?


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"

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

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.

Thank you.


Solution

  • I chose PowerShell for this porpose.

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

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