4

Is there any way to get the current servername from an Analysis Services instance? Basically the same as SELECT @@SERVERNAME but for SSAS.

I have looked into SELECT * FROM $system.DISCOVER_INSTANCES but that returns an error:

The 'INSTANCE_NAME' restriction is required but is missing from the request. Consider using SYSTEMRESTRICTSCHEMA to provide restrictions.

When attempting to use the SYSTEMRESTRICTSCHEMA I get the same error. When attempting to use INSTANCE_NAME I get the same error. When attempting to use the SYSTEMRESTRICTSCHEMA and specifying INSTANCE_NAME I get the same error.

Any help or insight is appreciated!

Ddono25
  • 41
  • 1
  • 2

2 Answers2

1

This will give you Server Name:

select [Value] as ServerName from $SYSTEM.DISCOVER_PROPERTIES where [PropertyName] = 'ServerName';

You don't need $system.DISCOVER_INSTANCES, but the syntax for that is:

select * from SYSTEMRESTRICTSCHEMA($SYSTEM.DISCOVER_INSTANCES, INSTANCE_NAME='MSSQLSERVER');
MRizza
  • 71
  • 1
  • 2
0

You are facing the error because the necessary parameters are not supplied to the functions. See here and here to understand how to pass parameters to these functions.

SouravA
  • 5,147
  • 2
  • 24
  • 49