Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support variable substitution #12

Open
SqlQuantumLeap opened this issue Dec 14, 2015 · 0 comments
Open

Support variable substitution #12

SqlQuantumLeap opened this issue Dec 14, 2015 · 0 comments
Assignees

Comments

@SqlQuantumLeap
Copy link
Owner

Allow substitution of $(var_name) variable.

This also requires handling:

  • -v command-line switch
  • :setvar SQLCMD command
  • checking all 3 levels of environment variables
  • -x ignore scripting variables

The following notes are taken from the MSDN page for the sqlcmd Utility:

Variable Precedence (Low to High)

  1. System-level environmental variables.
  2. User-level environmental variables
  3. Command shell (SET X=Y) set at command prompt before running sqlcmd.
  4. sqlcmd -v X=Y
  5. :Setvar X Y

NOTES:

  • SQLCMD processes commands and variable substitution per each batch!
  • Scripting variable names are case-insensitive
  • If no value is assigned to a sqlcmd environment variable, the variable is removed.
  • Using :setvar VarName without a value clears the variable.
  • SQLCMD commands inside of block comments and string literals are not processed.
  • See also: Use sqlcmd with Scripting Variables
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant