Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Obtaining the server name

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
If I am working on a SQL server database am I able to obtain the name of the server I am currently on by using the SQL command 'SELECT [srvname] FROM [sysservers] WHERE [srvid] = 0' if I am connected to the 'master' database ?
Would this always give me the server name ?
Thanks in advance.
Steve
 
Rather than relying on being in master and selecting from system tables etc

you could use

select @@SERVERNAME

Hope this helps,


Chris Dukes
 
Thanks again Chris - this has allowed me to get the server name as required.
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top