Solved

How do I get the name of the server that the DSN connected to?

Posted on 2010-08-15
5
389 Views
Last Modified: 2012-05-10
Hi,

Say, I have two DB Servers(server1 and server2). I have a DSN (Data Source Name) named mydsn. It should be connected to server1. My program should ensure that mydsn is mapped to server1.

How do I get the name of the server that the DSN connected to?

Thank you.
Regin
0
Comment
Question by:Fi-es
5 Comments
 
LVL 7

Expert Comment

by:bclongacre
ID: 33443436
If you are looking specifically to see what server you are getting a response from.

Click Start
Click Run
Type CMD
Press Enter

Type "nslookup", not including quotes, a space then any computer name, IP Address, or web site, and first entry will list the Server queried.

If you want to see what your DNS server settings are you can do the following:

Click Start
Click Run
Type CMD
Press Enter

Type "ipconfig /all" not including quotes then press Enter
0
 
LVL 7

Expert Comment

by:bclongacre
ID: 33443444
My apologies, I had a dyslexic moment, and read DNS as opposed to DSN, and I did not realize it until after I hit the Submit button.
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 33443469
you have to connect using the DSN, and then query for the server name:

select @@server

the issue is that even if a "server name" is written in the connection information of the DSN, it could still be an alias.
only connecting and running the above query will give the full instance name actually...
0
 
LVL 4

Expert Comment

by:Audhi203
ID: 33443616
Start -> Control Panel -> Admin Tools -> Data Sources -> Check with the DSN you created if Server name is correct. Also http://support.microsoft.com/kb/138541
0
 

Author Comment

by:Fi-es
ID: 33443748
Thank you all for your help.

Audhi203,
I donot want to manually verify the server. But my program has to ensure if the client machine is connected to the right server.

angelIII,
your solution solves my problem. Your query has a careless mistake.
Right query is
select @@SERVERNAME
I am going to accept your reply as the solution.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Where clause in stored procedure 8 64
How to query LOCK_ESCALATION 4 42
Getting max record but maybe not use Group BY 2 36
Sql Server group by 10 48
So every once in a while at work I am asked to export data from one table and insert it into another on a different server.  I hate doing this.  There's so many different tables and data types.  Some column data needs quoted and some doesn't.  What …
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question