go-sqlcmd
go-sqlcmd copied to clipboard
Scripting variables are not expanded in :out and :r commands
Hello Everyone,
in mssql-tools a SQL script can use variables even when composing a file path in :out and :r commands.
The go version is not able to expand variables in the filename of these commands:
:on error exit
:setvar WorkingDir ./tmp
:out $(WorkingDir)/file.sql
GO
PRINT '-- Test file.'
GO
:out stdout
GO
:r $(WorkingDir)/file.sql
GO
and leads the SQL script above to the following errors:
Sqlcmd: Error: Error occurred while opening or operating on file $(WorkingDir)/file.sql (Reason: open $(WorkingDir)/file.sql: no such file or directory).
Sqlcmd: Error: Error occurred while opening or operating on file $(WorkingDir)/file.sql (Reason: open $(WorkingDir)/file.sql: no such file or directory).
Tested on both v1.5.0 and v1.6.0.
TIA, Matteo