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
MAX/MINworks fine on strings.