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