tomos
tomos

Reputation: 21

How to know my server name in SQL Server?

I installed SQL Server but I forgot my server name and now that I install SQL Server Management Studio, it needs the server name.

How can I get server name again?

Upvotes: 2

Views: 59871

Answers (3)

You can get your server name with Transact-SQL(T-SQL) as shown below:

SELECT @@SERVERNAME                    -- DESKTOP-OVPADTC\SQLEXPRESS
SELECT SERVERPROPERTY ('ServerName')   -- DESKTOP-OVPADTC\SQLEXPRESS

Upvotes: 6

Shady
Shady

Reputation: 124

When the ssms's launched, the "Connect to Server" appears first,

then in the Server name field it'll have already selected (probably your pc name if you gave default on server installation) the server name.

If it isn't there, then click on it (Server name drop down)
<Browse for more...>
then on the popup "Browse for Servers"
click on "Database Engine"
and you can find your server name there.
There will be only one server name there ,if this is the first server you've created.
Click on the server name and hit OK!

Upvotes: 2

marc_s
marc_s

Reputation: 754200

If you installed SQL Server on your local machine, you can get to the installed server using

.
(local)
localhost
YourMachineName

as the server/instance name.

If you installed SQL Server Express with the defaults, you can reach your instance with:

.\SQLEXPRESS
(local)\SQLEXPRESS
localhost\SQLEXPRESS
YourMachineName\SQLEXPRESS

Otherwise, you need to go to Start Menu > SQL Server > Configuration Tools > SQL Server Configuration Manager and see which SQL Server services are running:

enter image description here

If you find a Service Type = SQL Server with a State = Running, the instance name is provided in the brackets behind the "SQL Server" in the Name column - here it is SQL2014. In that case, you can connect to this running SQL Server instance on your local machine using:

.\SQL2014
(local)\SQL2014
localhost\SQL2014
YourMachineName\SQL2014

If the instance name (in brackets) is MSSQLSERVER, this means it's the default, unnamed instance - and you can connect to it with just one of the first four options - just the "local machine server name" - no instance needs to be provided.

Upvotes: 2

Related Questions