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 (http://blog.SQLAuthority.com)












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
IMPORTANT: Your problem might be the name of the instance instead of the server. To find out use select @@servicename instead
Hi everyone, i’m installing Primavera 6 for which i need server name which actually comes through SQL server management studio express but the problem is i can’t see anything in server name box. Even though, if i went for browse for more i’ld not retrieve any server list/name. Please help me i really need a server name otherwise i can’t install my software.
it is an asp application that will work with sql database.when i run it i get the this error message on my browser.
error CS0006: Metadata file ‘C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll’ could not be found
what is this means do i need to modify the code on my application i use an asp .net application.
thanks a bunch
how to transfer data or view data from one server to another server
One option is to make use of Linked Server
to the point, crisp information in simple language. great stuff.
why dont u all understand we are looking for the problem that server name is not found in sqlserver during establishing connection to object explorer server name does not appear ..
very helpful….
i am using ms sql server express edition 2005. on the startup it asks for ‘servername’ to connect the server. how i got the servername when i want to run the queries on my pc only