I've been trying to pass a variable value that i can enter in the command line to open a batch file and then pass that value to an sql script. In this instance I'm looking to change a database user's password to a new password by setting it in the command line.
command line - update_passwords.bat server_name 1234
batch file -
@echo off
set sql_server_name=%1
set newPass=%2
osql -S %1 -U dbuser -P user_pass -v newPass=%2 -i c:\sql_script -o c:\sql_log
sql file -
ALTER LOGIN user1 WITH PASSWORD = %2;
I get an incorrect syntax near '%' error when I run the the batch file
Any help is greatly appreciated
sqlcmdlet's you use-vfor script variables butosqldoes not. To refer to it I believe you use this syntax:$(newPass)