Few days ago, there was complex condition when we had one database on two different server. We were migrating database from one server to another server using nightly backup and restore. Based on database server stored procedures has to run different logic. We came up with two different solutions.
1) When database schema is very much changed, we wrote completely new stored procedure and deprecated older version once it was not needed.
2) When logic depended on Server Name we used global variable @@SERVERNAME. It was very convenient while writing migrating script which depended on server name for the same database.
Syntax:
SELECT @@SERVERNAME AS 'Server Name'
ResultSet:
Server Name
——————–
SQLAUTHORITY
Reference : Pinal Dave (https://blog.sqlauthority.com)
35 Comments. Leave new
Thanks
That helped me, Very useful
oh, nice post.
thanks…
Thank you for the post
After changing the server name, the @@SERVERNAME still returns the old server name, any idea where @@SERVERNAME is stored so that I can update it to reflect the new server name?
After changing the server name, the @@SERVERNAME still returns the old server name, any idea where @@SERVERNAME is stored so that I can update it to reflect the new server name?
It seems that SERVERPROPERTY(‘servername’) returns the new name of the server.
@Goerge
Did you restart your SQL Server Instance after you changed name?
Also is it a default instance or named instance ?
~ IM.
Yes, we restarted the default instance after renaming the server.
I’m not sure why the @@SERVERNAME has the old name, but at least the SERVERPROPERTY(‘servername’) returns the new server name.
how to connect sql server 2008 and i don’t know server name of this, how to find before connecting.
how to connect sql server 2005 and i don’t know server name of this, how to find before connecting.
An error has occured while establishing a connection to server.when connecting to sql server 2005,this failure may be caused by the fact that under the default setting sql server does not allow remote connection ,(provider:Named pipes provider,error:40-could not open a connection to sql sever )(Microsoft sql server error;53)
That command gives you the server instance name which is only helpful if it is the name of the server. If you are in a clustered environment of want the actual physical name of the server run this…
SELECT SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’);
That command gives you the server instance name which is only helpful if it is the name of the server. If you are in a clustered environment of want the actual physical name of the server run this…
This only works on SQL 2005 and above though.
SELECT SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’);
The problem arises on Windows 2008. SELECT SERVERPROPERTY(‘ComputerNamePhysicalNetBIOS’) will return SQL virtual name rather then physical node name.
How can i know my SQL server name?
Please give me some idea about SQL server…
select @@SERVERNAME
pls help me i’m using windows 7 professional
i’m getting this error when i connect to sql server..
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
hi,
how can i find the server name from the run command…?
Can i get the command plz…….
pls help me i’m using windows 7 enterprise
i’m getting this error when i connect to sql server..
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)
I have the same error message :
” A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1)”
Can anyone help me
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server)
i am trying to connect to sql server from asp.net page i am getting this error.my server name-NISHITHA-PC\SQLEXPRESS that is local system . i am using sql server 2005
what is the proble
how to find out ms sql management studio express 2005 server name
use this
select @@servername
where should we type it? when I dont have sql server name I cannot be connected to sql server to type this query?!