SQLCMD: Prompt for Variable?

后端 未结 2 1467
生来不讨喜
生来不讨喜 2021-01-25 18:15

Coming from an Oracle background, Oracle\'s SQLPlus would let you indicate a variable. If the variable wasn\'t set, you\'d be prompted to provide a value.

I\'m using SQ

2条回答
  •  失恋的感觉
    2021-01-25 18:45

    SQLCMD does not support prompting for missing variable names. However, you can use SSMS in SQLCMD mode. Dunno how you're error was caused, but this works for me:

    :setvar table "sys.tables"
    
    SELECT * FROM $(table);
    

提交回复
热议问题