How To Find MSSQL Server Name on Local Machine

1 day ago 6
ARTICLE AD BOX

We are shipping a product installation that runs some SQL scripts on the local SQL server on installation.

It has worked well before, as we used the "localhost\sqlexpress" which most had as a standard.

But now, I believe after MSSQL 2019(?), it does not work anymore and has sometimes "localhost" or "[computername]\localhost" and others.

I do not find any servername that seems to be universal for all versions of MSSQL.

Is there a regkey, some cmd command or any function in any standard c# library i can run to get the Server name programmatic?

Thanks for your help.

Johan
Read Entire Article