I am running a .sql script through sqlcmd in a cmd shell and would like the script to emit my PRINT output in color.
How to echo with different colors in the Windows command line demonstrates how the Windows 10 CMD supports ANSI escape sequences.
I am guessing sqlcmd runs it's own cmd shell because the colors don't appear.
sqlcmd -S (LocalDB)\MSSQLLocalDB
> print 'NOTE: my message'
> go
NOTE: my message <--- Appears white on black.
In the next print there is ^[.
^[ is how the command shell renders a literal escape character.
The literal escape is entered from the keyboard using key combination Alt-Keypad 027.
> print '^[92mNOTE: my message ^[0m'
> go
□92mNOTE: my message□0m <--- Would like this to appear bright green on black
The sqlcmd shell is not supporting ANSI escape sequences. The escape character is output as a box (□) glyph and 92m sequence for bright green does not get interpreted.
Can the sqlcmd shell be configured to support the ANSI escape sequences?
I am using Windows 10 and SQLExpress 2016.
>sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 11.0.2100.60 NT x64
Copyright (c) 2012 Microsoft. All rights reserved.
A closer read of [sqlcmd utility documentation][1] under "Miscellaneous Commands" shows the feature
So the ECHO command can be issued with ANSI escape sequences to get coloring
:!!ECHO <alt-027>[1;32mThis is bright green.<alt-027>[0m This is not.