Create SP on Multi-Server Query

  • I have a dilemna. I like to use multi-server quesier to push out my code; however, all my SP's use DMV's or sys.ViewName. These are obviously incompatible with Earlier legacy systems of SQL Server. So what I would like to do, is check for the version number, if it equal or less than 8, return out of the SP Create command.

    So I initially wrote a statement and placed it at line one of the SP:

    if left(cast(ServerProperty('ProductVersion') as varchar), 1) = '8' return

    go

    The problem is the go statement, it processes the return and go statements then just moves on the the next line of code, which is to check for the existance of a DB in sys.databases (obviously breaks for SQL 7/2000 as no such table or view existed).

    So my short question; is there a way to prevent, during a multi-server query/execution, the execution of a Create SP if the version of the server is 7/2000?

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • Are you using a server group or linked servers?

  • Server Group

    /* ----------------------------- */
    Tochter aus Elysium, Wir betreten feuertrunken, Himmlische, dein Heiligtum!

  • Yeah, I've tried that before to no luck. Any T-SQL inside the switches are all evaluated BEFORE the switches and they'll fail if the version isn't correct. You might have better luck with linked servers..or contrariwise set up another server group with only servers that are 2005 and above for your procedure push.

Viewing 4 posts - 1 through 3 (of 3 total)

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