问题
I'd like to login to my SQL Server 2012 Express with servername local
or (local)
but it doesn't work.
The only servername which works is PC-Name\SQLEXPRESS
.
local/(local)
has to work somehow because I have to use the following connection string:
Data Source=localhost;Initial Catalog=...
回答1:
I've reinstalled it and ensures to select "default instance" instead of "named instance" during the installation. Now everything is fine again.
回答2:
I think I see what you're trying to do now.
If you really don't like using the hostname\instance combination and you are using the SQL native client to connect, you can always add an alias in the native client called local that resolves to your instance. That way you can keep your connection string in your application the same no matter what server/instance you end up sticking the application on just by changing the alias.
See the link below for details on how to configure:
How to setup and use a SQL Server alias
来源:https://stackoverflow.com/questions/15023131/sql-server-2012-login-to-pc-name-sqlexpress-works-but-not-to-local-local