SQL Server 2012 sqlcmd: Unexplained behaviour returning output containing square brackets [] - by swh1

Status : 

  Won't Fix<br /><br />
		Due to several factors the product team decided to focus its efforts on other items.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 812101 Comments
Status Closed Workarounds
Type Bug Repros 3
Opened 12/20/2013 6:40:51 AM
Access Restriction Public


From a SQL Server 2012 installation (SQL Server 2012 patched to sp1 (11.0.3000.0); and sqlcmd reporting: Version 11.0.2100.60 NT x64), executing either:

sqlcmd /E -S <ServerName> -Q "PRINT '[A], [B], [C]'" or

sqlcmd /E -S <ServerName> -Q "PRINT CHAR(91) + 'A], [B], [C]'"


, [B], [C]

wheras for 2005, 2008 or 2008R2, gives the expected result of:-

[A], [B], [C]

I haven't been able to find an explanation or way to force the correct result from 2012 sqlcmd.  It appears to me that 2012 is interpreting a lefthand square bracket as the first character on a line as some sort of token delimiter or similar.

Can anyone shed some light on this?  This is just an example of the problem, I am not actually trying to print [A], [B], [C]! :) -  we are experiencing data loss/corruption on outputs from stored procedures where the leftmost character is [.

Note that 2012 sqlcmd expects a closing ] on the line, otherwise the output gets returned like this for:-

sqlcmd /E -S <ServerName> -Q "PRINT '[A, [B], [C'"

[Microsoft][SQL Server Native Client 11.0][SQL Server][A, [B], [C


(Virtualization: VMWare)
Sign in to post a comment.
Posted by swh1 on 2/28/2014 at 12:35 AM
Seems like this feedback has fallen on deaf ears!!
Posted by swh1 on 12/23/2013 at 1:40 AM
The workaround posted by Balmukund is not strictly a workaround. To achieve this (adding a leading space), we would need to check and edit hundreds of stored procedures, and there will be secondary affects by adding characters to the output.