首页 > 解决方案 > 从 CSV 导出中删除双引号

问题描述

我在 SP 中有以下部分代码,它将一些结果导出到 CSV。我尝试将 ConvertTo-Csv -NoTypeInformation更改为ConvertTo-Csv -NoTypeInformation -Delimiter ",",但它只是不会将文件导出到路径。

SET @cmd = 'Invoke-Sqlcmd -Query ''SELECT * FROM '+@tablename+';'' -Database '+@dbname+' -Server "'+@servername+'" -Username '+@username+' -Password '+@password+
        ' | ConvertTo-Csv -NoTypeInformation | select -Skip 1 | Set-Content -Path '+@folderpath+'\'+@filename+' -Encoding UTF8'
SET @cmd = 'powershell.exe -noprofile -command "'+@cmd+'"'
EXEC @return = xp_cmdshell @cmd, no_output
    IF @return <> 0
    BEGIN
        PRINT 'ERROR: '+@cmd
    END

如何在没有双引号的情况下将其导出?

标签: sql-servertsql

解决方案


推荐阅读