@@SERVERNAME returns hostname portion in lowercase

Peter Bishop 161 Reputation points
2021-10-28T09:51:14.33+00:00

I have a newly-built SQL 2019 instance and when I run @@SERVERNAME, the response I get is:

hostname\INSTANCENAME

where:

  • hostname is in lowercase
  • INSTANCENAME is in uppercase

Any ideas why this might be happening? If the instance name was lowercase, I'd put it down to me typing it that way during installation.

The Windows %COMPUTERNAME% variable returns the value in UPPERCASE.

Thanks.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,058 questions
{count} votes

Accepted answer
  1. YufeiShao-msft 7,071 Reputation points
    2021-10-29T06:11:25.64+00:00

    Hi @Peter Bishop ,

    This may be because %computername% returns uppercase, but not the real computer name
    https://www.tenforums.com/general-support/158126-computername-returning-upper-case-name.html

    you can try to find the real name using hostname or from the settings>system>about

    -------------

    If the answer is the right solution, please click "[Accept Answer][4]" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our [documentation][5] to enable e-mail notifications if you want to receive the related email notification for this thread.


2 additional answers

Sort by: Most helpful
  1. Erland Sommarskog 103.2K Reputation points MVP
    2021-10-28T21:51:31.97+00:00

    I don't know why that may be happening. What does SELECT serverproperty('ServerName') return?

    Anyway, you can try this:

    EXEC sp_dropserver 'lowercase\INSTANCE'
    EXEC sp_addserver 'UPPERCASE\INSTANCE', 'local'
    

    and then restart SQL Server.

    0 comments No comments

  2. Emrah Saglam 0 Reputation points
    2023-04-20T08:40:24.97+00:00

    If you prepare your server with lowercase with SQL Server 2019 Case Sensitive Instances you will start to get some error like below for Ola's MaintenanceSolution, Netbackup for Alwayson Backups, etc because this king of tools uses some SQL built-in functions. The @@SERVERNAME does not match SERVERPROPERTY('ServerName'). See https://docs.microsoft.com/en-us/sql/database-engine/install-windows/rename-a-computer-that-hosts-a-stand-alone-instance-of-sql-server I think Microsoft should offer to customers to setup their servers with uppercase depending on SQL Server 2019 built-in function's returned case sensitive values anymore. UPPER Server name is best practice.

    0 comments No comments