Ddono25
Ddono25

Reputation: 51

Get Instance Name from Analysis Services like @@ServerName

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

Answers (2)

MRizza
MRizza

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

SouravA
SouravA

Reputation: 5253

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.

Upvotes: 0

Related Questions