Server Name column in Multiserver Results

  • The Server Name column that is returned with multiserver queries (if the option is set to True), can it be referenced in a GROUP BY or HAVING clause? I have been able to somewhat work around it by using @@servername and doing a join on sys.servers. But I would prefer to use less code, if it is possible.

  • Is it a named column in the query? If so, try grouping by it in a proof of concept query.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • No, it is added to the results if you go to OPTIONS->Query Results->Multiserver Results-> and make Add server name to the results TRUE.

  • Can you insert those results in a temp table and then query that?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Nope...the [Server Name] column appears to be appended by the IDE, not on the server-side.

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

  • Can you explicitly add @@servername to the query and use that?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Yes, that is what I am doing. I was just hoping that I would be able to use the supplied column. Thanks.

  • I think @@servername is what you're stuck with.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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