brutzen
brutzen

Reputation: 17

Select SQL Server Server's Alias

Is there a way I can select the alias of a SQL Server? For example, I have a server on a box that is named PRODSQL02 but users generally know and connect to this box as PROD.

I have been using @@SERVERNAME but the end recipients of this information don't always understand that PRODSQL02 = PROD.

Upvotes: 0

Views: 105

Answers (2)

Tab Alleman
Tab Alleman

Reputation: 31785

You can do

SELECT REPLACE(@@SERVERNAME, 'SQL02','')

Which removes the 'SQL02' portion of any servername.

Upvotes: 1

Aleem
Aleem

Reputation: 82

You can use substring like this SELECT SUBSTRING(@@SERVERNAME, 1, 4) to just get prod out of the value.

Upvotes: 0

Related Questions