No @@ServerName on Linux

I setup a new instance of SQL Server on Linux some time ago. At the time, the Linux machine didn’t have any Samba running, and no real “name” on the network. As a result, after installing SQL Server I got a NULL when running SELECT @@SERVERNAME.

The fix is easy. It’s what you’d do if you had the wrong name. You run:

sp_addserver ‘Ubuntu’, Local

In this case, Ubuntu was the name I gave my machine under the Samba server, since that’s the OS. I don’t plan on adding more for now, so this is fine.

After the chance, I couldn’t restart the instance from SSMS, so on the host itself, I ran a

sudo systemctl stop mssql-server
sudo systemctl start mssql-server

That completed, and my @@servername is now working.

About way0utwest

Editor, SQLServerCentral
This entry was posted in Blog and tagged , , . Bookmark the permalink.

One Response to No @@ServerName on Linux

  1. Pingback: Missing @@SERVERNAME On Linux – Curated SQL

Comments are closed.