0

I am running a query over a server group containing, say, 5 instances...each of which have a database called TESTDB...and the server group is set to access only this database from each registered server within the server group.

I am running a query such as follows :

select serverproperty('servername'),file from testdb_table

to get something like :

col 1       col2
instance-1 file1
instance-1 file2
instance-1 file3
instance-2 file1
instance-2 file2
instance-2 file3
instance-3 file1
instance-3 file3

which gives me the instance and the file in 2 separate columns.

Since the server group has 5 registered servers, I will see these registered servers in the first column whereas the file field will show in column 2.

I need to be able to pivot this data in a way so as to get something like :

INSTANCE-1     INSTANCE-2     INSTANCE-3
file1            file1          file1
file2            file2           
file3            file3          file3

etc.

The file field is a string field.

Since this query may be used on different server groups, I will not be able to know how many there are or what they are...so the query needs to be somewhat dynamic...

Thank you

3
  • 1
    Why the "No aggregates" restriction? Or you just don't see how they will be useful to you? Commented Dec 23, 2013 at 18:25
  • Because the values undearneath Field 2 will actually be strings... Commented Dec 23, 2013 at 18:54
  • MAX/MIN works fine on strings. Commented Dec 23, 2013 at 18:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.