Share via

ODBC SERVER NAME EXTRACTION

Dan Bowler 41 Reputation points
2022-07-22T05:13:08.367+00:00

I have a desktop application that connects to varying server computers' SQL databases based on the ODBC server name I manually plug into the ODBC DataSource. I'd like to display that server name in my application. Can someone help me figure out how to retrieve the 'connect to' server name from either the ODBC DataSource or perhaps from the SQL server itself?

Windows for business | Windows Client for IT Pros | User experience | Other
SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories


Answer accepted by question author

Olaf Helper 47,621 Reputation points
2022-07-22T05:21:24.327+00:00

or perhaps from the SQL server itself?

That's simple, run this query:

select @@SERVERNAME  

Was this answer helpful?

1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.