I have the following script that I want the production guys to execute using sqlcmd开发者_如何学JAVA. I want to pass the name of the APP_POOL_USER as a variable to the script, since they want it that way. Don't ask me why.
CREATE USER [$(APP_POOL_USER)] FOR LOGIN [$(APP_POOL_USER)]
WITH DEFAULT_SCHEMA=[schema]
I get the following error when I execute the code above
Msg 15007, Level 16, State 1, Line 2 '$(APP_POOL_USER)' is not a valid login or you do not have permission.
How can this be done?
EDIT:
This is the batch file to execute it I have so far
@ECHO OFF
SET DB_SERVER_NAME = ".\SQLEXPRESS"
SET APP_POOL_ACCOUNT = "ExUserAccout"
sqlcmd.exe -E -S "%DB_SERVER_NAME%" -i "SQL_DB.sql" -o SQL_DB.log -v APP_POOL_USER="%APP_POOL_ACCOUNT%"
The solution was in the batch file.
@ECHO OFF
SET DB_SERVER_NAME=.\SQLEXPRESS
SET APP_POOL_ACCOUNT=ExUserAccout
Don't leave spaces between the equal sign and the variable name and value.
精彩评论