Home Forums SQL Server 2008 T-SQL (SS2K8) SQLCMD variable scripting - injecting a variable into another RE: SQLCMD variable scripting - injecting a variable into another

  • I spent a few minutes looking around and experimenting and I did not see a way to do it. I don't know everything you're trying to do, however while it may not be your preference this technique might work for you:

    :SETVAR DB_NAME_ASSIGN "TEST TEXT"

    :SETVAR DB_NAME_TEXT "EXPECT INSERT OF DB_NAME_ASSIGN HERE: "

    /*Get output*/

    SELECT '$(DB_NAME_TEXT)' + '$(DB_NAME_ASSIGN)' AS OUTPUT

    /* Delivers:

    EXPECT INSERT OF DB_NAME_ASSIGN HERE: TEST TEXT

    */

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato