Search code examples
sql-serverazure-devopsazure-sql-databasedacpacsqlpackage

SQL Server SqlPackage variables: are quotes needed around string variable?


When running sqlpackage.exe for deployments, do string variables require quotes around the word? It seems to be running successfully both ways. What is the correct syntax?

Two options shown here:

/v:CompanyName=ABCD

/v:CompanyName="ABCD"

Resource: https://learn.microsoft.com/en-us/sql/tools/sqlpackage/sqlpackage?view=sql-server-ver15


Solution

  • @Jeroen Mostert is right. It's more related to the command line not only the SqlPackage.

    If the string variable contains spaces equality signs, slashes, or anything else that would interfere with option syntax, the value must be surrounded in "quotes".

    Here is the example blog: https://www.addictivetips.com/windows-tips/enter-file-or-folder-paths-with-spaces-in-command-prompt-on-windows-10/

    If all of the following conditions are met, then quote characters on the command line are preserved:

    • No /S switch (Strip quotes)
    • Exactly two quote characters
    • No special characters between the two quote characters, where special is one of: & < >( ) @ ^ |
    • There are one or more whitespace characters between the the two quote characters
    • The string between the two quote characters is the name of an executable file.

    Ref: https://ss64.com/nt/syntax-cmd.html

    HTH.