Results formatting problem

Single-click script execution on multiple SQL Servers.

Moderators: JonathanWatts, Anu Deshpande, dlkj, Colin Millerchip, Michelle Taylor

Results formatting problem

Postby tkdennis » Thu Nov 05, 2009 11:21 pm

I'm running a short script that produces text with both _ and " in the results.
Code: Select all
DECLARE @s VARCHAR(MAX), @servername sysname
SELECT @s = '', @servername = REPLACE(@@SERVERNAME, '\\', '_')
SELECT @s = 'md "C:\\_\\SQL Compare\\Servers\\' + @servername + '"' + CHAR(13) + CHAR(10)

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 -?


SQL Multi Script
Posts: 75
Joined: Fri Feb 29, 2008 1:13 am

Postby dlkj » Fri Nov 06, 2009 12:46 pm

Hi tkdennis,

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).

Daniel Kenyon-Jones
Software Engineer - DBA Tools
Posts: 151
Joined: Tue Aug 14, 2007 5:10 pm
Location: Red Gate Software, Cambridge

Return to SQL Multi Script 1

Who is online

Users browsing this forum: No registered users and 0 guests