Share via

How to retrieve ALIAS definitions used by SQL Server from command line

Andreas Cichy 1 Reputation point
Oct 19, 2022, 8:43 AM

Hi

I need to obtain the ALIAS definitions from a SQL Server installation for further processing. So anything that has to do with interface doesn't help.

In some installations I can fetch the ALIAS definitions from registry by executing

reg query HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo
reg query HKLM\SOFTWARE\Microsoft\MSSQLServer\Client\ConnectTo
reg query HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\MSSQLServer\Client\ConnectTo
reg query HKLM\SOFTWARE\WOW6432Node\Microsoft\MSSQLServer\Client\ConnectTo

Unfortunately this doesn't work on some SQLServer installation (i.e. 14.00.3162).

Is there any other way to get the ALIAS definitions ? Maybe by running a query against a system table ?

Andreas

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,494 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. Olaf Helper 46,546 Reputation points
    Oct 24, 2022, 9:36 AM

    It looks like newer SQL Server versions store the ALIAS definitions somewhere else.

    SQL Server don't store it, it's still a client setting in registry and independent of the used SQL Server version(s).
    Nothing has changed, the alias defintion is still stored in registry at the same place.
    And if you don't get one, then because no alias is defined.

    0 comments No comments

  2. Tom Phillips 17,766 Reputation points
    Oct 24, 2022, 9:03 PM

    What you are describing are "aliases" coming from the SQL Server Native Client. The SQL Server Database Engine has no knowledge of these aliases.

    If you do not find any references in the registry, it is possible you are using "DNS" aliases. In which case, you will not find this in the SQL Server registry.


Your answer

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