Reputation: 51
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!
Upvotes: 5
Views: 4764
Reputation: 71
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');
Upvotes: 1