Reputation: 17
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
Reputation: 31785
You can do
SELECT REPLACE(@@SERVERNAME, 'SQL02','')
Which removes the 'SQL02' portion of any servername.
Upvotes: 1
Reputation: 82
You can use substring like this SELECT SUBSTRING(@@SERVERNAME, 1, 4)
to just get prod out of the value.
Upvotes: 0