Results formatting problem
tkdennis
Posts: 114
I'm running a short script that produces text with both _ and " in the results.
If I display in Text format, the _ is converted to a -
md "C:\-\SQL Compare\Servers\SERVER1-DEV"
If I display in Grid format and copy to clipboard, the whole text is wrapped in double-quotes so every " in the result set is doubled up.
Is there a way to stop the Text display from changing all the _ to -?
Thanks,
Traci
SQL Multi Script 1.1.0.34
DECLARE @s VARCHAR(MAX), @servername sysname SELECT @s = '', @servername = REPLACE(@@SERVERNAME, '\', '_') SELECT @s = 'md "C:\_\SQL Compare\Servers\' + @servername + '"' + CHAR(13) + CHAR(10) PRINT @s
If I display in Text format, the _ is converted to a -
md "C:\-\SQL Compare\Servers\SERVER1-DEV"
If I display in Grid format and copy to clipboard, the whole text is wrapped in double-quotes so every " in the result set is doubled up.
Is there a way to stop the Text display from changing all the _ to -?
Thanks,
Traci
SQL Multi Script 1.1.0.34
Comments
You're right, the text display is a bug. Looks like something is not getting escaped properly. I'll look into that.
The grid view is correct. As the results contains white space characters, the cell value has to be wrapped in quotes. Any quotes in the results are escaped using double quotes as well. This ensures that the output can be pasted into excel or other spreadsheet application.
A temporary work around would be to remove the new line from the end of your result string, paste the results into excel and then save the excel sheet to a text file. (Not idea, but we'll see what we can do about fixing the text output).
Cheers,
--
Daniel Kenyon-Jones
Software Engineer - DBA Tools