Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to export 'PRINT' commands into a file via bcp?

I want to export a result of a PRINT command. I don't want to use the normal SQL Server logs. Is that possible with bcp? Because the following command does not work.

Example:

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

Result:

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
like image 824
WIbadeneralp Avatar asked Dec 19 '25 16:12

WIbadeneralp


1 Answers

Print is not a query but Select is.. Try Select instead of Print

SET @IPE = 'bcp SELECT ''Test''  queryout ' + @Path + '1b_Log_change_log_entry.txt -c -T'
like image 64
Pரதீப் Avatar answered Dec 22 '25 09:12

Pரதீப்



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!