Problems with setvar variable ...

  • This code works:

    :setvar sourceDB 'master'

    select $(sourcedb)

    This code does not:

    :setvar sourceDB 'master'

    use $(sourcedb)

    Any ideas why???

    Thank you for you time! 🙂

  • Where is the Microsoft SQL Server 2005 related problem?


    N 56°04'39.16"
    E 12°55'05.25"

  • Peso (4/18/2008)


    Where is the Microsoft SQL Server 2005 related problem?

    I am trying to execute this in SQL Server 2005. I can use the variable in some ways ... but, not another. When I use the variable with a select statement - it works fine. But, when I try to use it to set the database (use ) it fails.

    I was hoping someone could help me out.

    The command that is failing is even in BOL under sqlcmd ... I'm not sure what I am doing wrong.

    Thanks,

    Jen

  • I mean, what client language is that?

    And where is it executed?


    N 56°04'39.16"
    E 12°55'05.25"

  • Peso (4/18/2008)


    I mean, what client language is that?

    And where is it executed?

    I am running it from within Management Studio ... after turning on SQLCMD Mode.

    SQLCMD is a command line utility in sql server 2005 which is taking the place of OSQL and ISQL.

  • it should work if you remove the single quotes around master:

    :setvar sourceDB master

    use $(sourcedb)

    ---------------------------------------
    elsasoft.org

  • Well, that would explain it. I just didn't see that. Thanks! 🙂

Viewing 7 posts - 1 through 6 (of 6 total)

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