SQL Server 2019: bad host name

Jaime Stuardo 71 Reputation points
2022-06-12T21:05:01.61+00:00

Hello, I have a Windows 10 PC with certain name according to this image:

210549-this-pc-info.png

well... I have installed SQL Server 2019, but strangely, the hostname is different. That causes an error when authenticating user:

210651-image.png

Why did this happen? and how can I solve it without reinstalling SQL Server 2019? Someday I tried to reinstall SQL Server but after uninstallation system got corrupted so I needed to reinstall Windows completely, so I fear to uninstall it.

SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2022-06-12T21:56:43.447+00:00

    I think the problem lies in that Friendly-SpA-III is 16 letters, and NETBIOS names are restricted to 15 letters.

    So I would recommend that you rename the computer. Once you have renamed it, check SELECT @@servername to see what it returns, then do:

       EXEC sp_dropserver <oldserverame>  
       EXEC sp_addserver 'NewName', 'local'  
    

    Also check sys.server_principals for logins with the old name and use ALTER LOGIN to fix those.

    If you rename the machine to Friendly-SpA-II, you may not have to do very much.

    1 person found this answer helpful.
    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Ronen Ariely 15,206 Reputation points
    2022-06-13T00:19:26.93+00:00

    Hi,

    Following Erland's answer, here is the document regarding Rename a Computer that Hosts a Stand-Alone Instance of SQL Server

    If you do not want to change the Computer name and you are connecting it locally, then instead of connecting using the machine name "Friendly-SpA-III\Instance_Name" you can sue any of the following solution to connect the SQL Server

    Option 1: you can try to use dot ".\Instance_Name"

    Option 2: You can try to use internal loop IP for the localhost which is usually 127.0.0.1 so you can use "127.0.0.1\Instance_Name"

    Option 3: You can use the word localhost "localhost\Instance_Name". The localhost word is the default name describing the local computer address also known as the loopback address.

    As you can see in the following image you can use all the above options to connect the local server
    210606-image.png

    Note: If your server is the default instance and you do not want to use the instance name then do the same without instance name

    1 person found this answer helpful.
    0 comments No comments

  2. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-06-13T03:02:22.56+00:00

    Hi @Jaime Stuardo ,

    Full agree with Erland and pituach. You have below solutions.

    1.Use sp_dropserver and sp_addserver to rename a computer that hosts a stand-alone instance of SQL Server.

    2.Use dot or localhost instead of your computer name Friendly-SpA-III.

    3.Rename your machine directly. I suggest you use this method, if you want to install other SQL server instance in your machine, this method works once and for all.

    •Select Start > Settings > System > About.

    •Select Rename this PC.

    •Enter a new name and select Next. You may be asked to sign in.

    •Select Restart now or Restart later.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

  3. Tom Phillips 17,771 Reputation points
    2022-06-15T14:02:35.737+00:00

    The server name has nothing to do with your actual problem. NetBIOS names must be unique in the first 15 chars. Your server name is fine.

    You are apparently trying to login to the server using a domain login in a different domain/workgroup which is untrusted. You must either trust the domain, in Active Directory, or use SQL Logins on the server.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.