I am using the following:
Powershell Command: Invoke-Sqlcmd -AbortOnError -InputFile "C:\FullPath\SQLQuery.sql" -ServerInstance WPU8V9011532 -Variable "PREF = 'NeededVal'"
SQLQuery.sql file content:
:setvar PREF "InternalVal"
USE $(PREF)MyDB Select * from ABC
What I need: To make the execution use "NeededVal" instead of "InternalVal".
Due to precedence rules, it doesn't work. Is it possible to override them? There are 100s of such files to execute and cannot be edited. Also, the servers of execution are multiple and repeatedly required (executions).