Can you please tell me how to set a variable in a bat file and use it as an argument in SQL CMD? Here it is necessary, that dbname was picked up.

set dbname = DESKTOP-11 sqlcmd -S $(dbname)-U sa -P pass -i "G:\CMDtest\script_1.sql" pause >nul 

    1 answer 1

     sqlcmd -S $(%dbname%) -U sa -P pass -i "G:\CMDtest\script_1.sql" 
    • Swears on the connection. The code is: set dbname = "DESKTOP-11" sqlcmd -S $ (% dbname%) -U sa -P 1111 -i "G: \ CMDtest \ script_1.sql" - Ssss