SQLCMD - Missing expression after unary operator...

  • Noob to using SQLCMD and getting this when running script from Powershell. Any help would be greatly appreciated!!!!

    PS C:\> SQLCMD -S CONTOSOWXP01\SQLEXPRESS CREATE LOGIN [NewUser] WITH PASSWORD = 'password', DEFAULT_DATABASE=[Mydatabase], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF

    Sqlcmd: 'CREATE LOGIN [NewUser] WITH PASSWORD = password DEFAULT_DATABASE=[Mydatabase] CHECK_EXPIRATION=OFF CHECK_POLIC

    =OFF': Unexpected argument. Enter '-?' for help.

    PS C:\> -?

    Missing expression after unary operator '-'.

    At line:1 char:2

    + - <<<< ?

    PS C:\>

  • Try this:

    SQLCMD -S CONTOSOWXP01\SQLEXPRESS -Q "CREATE LOGIN [NewUser] WITH PASSWORD = 'password', DEFAULT_DATABASE=[Mydatabase], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF"

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply