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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get the Servername currently connected

Status
Not open for further replies.

rajeshkanna

Programmer
Apr 24, 2002
9
IN
Hi,

Any one can help me to get the servername which i curretnly connected through CLIENT side Sql Server Query Analyzer.

I issued by "Select @@SERVERNAME"
It returns "Null"

how to return SERVERNAME.

Server version is SQL SERVER 7.0
 
Hi

You might just have put your sql statment in double quotes in your post but if you used the syntax like that then it won't work.

your syntax(unless you did this for the post):

"select @@servername"

should be:

select @@servername

I tried this against sql 6.5, 7 and 2000 and I got results back.
If you are in Query Analyser the Title Bar will display the servername, database name, login, and query name eg:

[spdcimp03.ips2live.mluaccount\osjohnm - untitled2*]

Hope that helps

John
 
Hi,

the double quote is to differentiate the sql statement from the line.

I run this stmt (without double quote) with query analyser itself.

Ok, It displays the servername on title of the window.
but the query not produced the result, it returns only Null.

I read the BOL help it says you can get the local server name only through select @@SERVERNAME statement.

I'm running on client's Query analyzer. According to the BOL help i think it is not possible to display the servername here.

anyway thanks lot.
Rajesh kanna. N
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top