1

Is there a way to get a script file that will be executing via SQLCMD to accept the parms passed in the SQLCMD call.. i.e. I need to input the DbName variable from the user. Below is the code I am using to automate an sql script file through cmd.

sqlcmd -S %SName% -U %UName%  -P %Pwd%  -v DbName="%DbName%" -i D:\SqlScripts\script.sql 

Also in my sql script file I am using $(DbName) to receive the passed variable. But it's not working.

Jos van Weesel
  • 2,128
  • 2
  • 12
  • 27
Aparna
  • 17
  • 3

0 Answers0