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

时间:2017-07-18 08:04:32

标签: 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

1 个答案:

答案 0 :(得分:2)

Print不是查询,但是Select是..尝试Select代替Print

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