SQL Server 2012: Login to PC-NAME\SQLEXPRESS works, but not to local/(local)

感情迁移 提交于 2020-01-04 05:28:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!