问题
I have two instances of SQL Server 2008 Express and one instance of SQL Server 2012 on my development machine. We're developing an ASP.NET MVC application and use the expression data source=(local); inside of our connectionString in Web.config.
Now my question is what is the logic behind this expression? Which instance gets chosen and how can I change this behavior?
回答1:
Using "local" you get the default instance which is usually the non-express SQL Server since by default in SQL Server Express installation the instance name is "SQLEXPRESS" and in full SQL Server installation by default you don't get an instance name unless you set it explicitly.
回答2:
(local)
just means means to use the SQL Server installed in the current Machine
Any of the following three
"(local)"
,"."
,".\\SQLEXPRESS"
can be used to make use of the SQL Server installed in the current Machine.
回答3:
Every instance has instance name, so you can specify source=(local)\INSTANCE_NAME.
You can check instance's and their names in sql server configuration manager.
回答4:
When you use data source="(local)";
It means it connects to SQL Server database on the local server
You can find more at microsoft references :
http://technet.microsoft.com/en-us/library/ms156450(v=sql.100).aspx
来源:https://stackoverflow.com/questions/12192184/logic-behind-data-source-local-in-connection-string