sql - 是否可以通过 bcp 将 'PRINT' 命令导出到文件中?

标签 sql sql-server bcp

我想导出 PRINT 命令的结果。我不想使用普通的 SQL Server 日志。 bcp可以吗?因为下面的命令不起作用。

例子:

SET @IPE = 'bcp PRINT ''Test''  queryout ' + @Path + '1b_Log_change_log_entry.txt -c -T'

结果:

Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 13 for SQL Server]BCP host-files must contain at least one column
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC Driver 13 for SQL Server]Unable to resolve column level collations
NULL
BCP copy out failed
NULL

最佳答案

Print 不是查询,但 Select 是。尝试使用 Select 而不是 Print

SET @IPE = 'bcp SELECT ''Test''  queryout ' + @Path + '1b_Log_change_log_entry.txt -c -T'

关于sql - 是否可以通过 bcp 将 'PRINT' 命令导出到文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45160888/

相关文章:

sql-server - SQL Server 历史表 - 通过 SP 或触发器填充?

sql-server - BCP:无法解析列级排序规则

sql - 在 oracle 10g 中连接三个表

sql - 删除 SQL 中括号内的文本

c# - SQL Server VARBINARY(max) 到 c# byte[]

bcp - 当 BCP 失败时 ("BCP copy in failed"),而不是生成的 -e 错误日志内容是什么意思?

sql-server - 为什么在 MS SQL Server 中批量插入时收到 "XML parsing: line 2, character 0, incorrect document syntax"

php - 带有重音字符的 SQL 查询

sql - 一对多查询sql

mysql - 如何在 MySQL 中选择其值位于 json 数组中的列