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?
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.
(local) just means means to use the SQL Server installed in the current MachineAny of the following three
"(local)" ,
"." ,
".\\SQLEXPRESS"
can be used to make use of the SQL Server installed in the current Machine.
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.
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
Related
I use management studio and SQL Server. How to change server name from (LocalDbs)\MSSQLLocalDB to localhost? When I connect to server in connection string I want to call: server='localhost
I believe, it's not good idea to change named instance to default instance as it might conflict with existing default instance, and considering consequences. However, \InstanceName is really concern for the connection string, you could have custom port assigned to that SQL Instance so that your connection string would be server=localhost,portnumber.
Please have a look at this answer at DBA.StackExchange to learn more on connecting SQL Server with custom port and how to change the port#
If you still have concern to use port number in connection string server=localhost,portnumber. My advise is to restore the database on SQL default instance (need to be installed if not existed already), then you could re-direct the application to communicate with default SQL Instance, this case your connection string would look like server=localhost
You could do following, if you want rename the Server in any case:
sp_dropserver <old_name>;
GO
sp_addserver <new_name>, local;
GO
I am facing server name problem in SQL Server 2012. When I click on configure distribution I get an error:
Unable to connect to server. Specify the actual server name.
I changed my server name and restarted the services but unable to connect through new server name.
Basically, I am doing this on local domain based server.
Kindly suggest a suitable solutions.
After you rename a SQL Server machine, you will also need to rename the SQL Server instance itself using:
sp_dropserver <old_name>;
GO
sp_addserver <new_name>, local;
GO
For more information, see Microsoft's article called Rename a Computer that Hosts a Stand-Alone Instance of SQL Server.
I think what your probably finding is that changing the Windows server hostname doesn't actually change the original SQL Server instance name which still gets used for certain services. Run the following on the DB engine:
SELECT ##SERVERNAME
You'll probably find a different value to what your expecting from the OS.
There isn't really a solution to this that I'm aware of without re-installing SQL Server on the newly named box.
Also be careful with names that exceed to the 15 character NetBIOS limit.
Can someone explain why after installation of SQL Server some PC get a suffix of \SQLEXPRESS and some don't? Is there an option to change it?
Any suggestions or tips would be appreciated.
That is the SQL Server instance name for the new SQL Server you installed. A single machine can host multiple instances of SQL Server. The naming convention you see: hostname\instance_name is used to identify the different SQL Server instances running on a single machine.
When you install SQL Server Express, the default instance name created is SQLEXPRESS.
See:
Default instance name of SQL Server Express
How to: Identify a SQL Server Express Instance
Instance Configuration
The hostname is used for machine to machine networking. That is the same name that is used for Netbios/SMB file sharing services (\\hostname) and normally resolved for TCP/IP services through DNS (http://hostname).
The hostname\instance_name is purely a SQL server naming convention. Its only purpose is to identify a running instance of SQL server. The SQL server client network libraries know how to resolve these instance names. The standard network stacks do not. This means the following do not work:
ping hostname\instance_name
\hostname\instance_name
http://hostname\instance_name
The \instance_name only works with SQL server network clients.
I have installed many SQL Server setups but I want to know how to install SQL Server without an instance name i.e. i want to connect to SQL Server with IP or server name only.
Installing an instance and connecting to an instance of SQL Server are two different things.
Every time you attempt an SQL Server installation you have to specify an instance (create a new one or select an existing one)
Connecting to an instance is a different thing.
For example if you want to connect to an instance through MS Management studio without writting the name of the instance you can define the connection in following manner:
ComputerName\IP,port
e.g:
MyPC\192.168.1.1,1433
In order to do this you need to install SQL Server as the default instance on the machine. When it is set as the default instance you no longer need to specify an instance name when connecting to it.
Each member of our development team has a copy of our application's database running on a local version of SQL Server 2008 Enterprise with SP1. Everyone is able to access the database by specifying their server and instance name in their web.config file, but to best share the developer version of our web.config file, we have standardized on making connections strings generic by using integrated security and setting server property to (local). This strategy is working fine for the majority of our 64-bit Windows 7 machines but in few cases (local) isn't recognized. We have compared settings via the SQL Server Configuration Manager (namely ensuring that the named pipes protocol was enabled) and we've tried setting the "(local)" alias via SQL Server Client Network Utility, but we haven't any luck. What needs to be done in order to use (local) in our connections strings?
Trying changing the Pipe Name for your instance to "\.\pipe\sql\query".
You can find that setting by starting SQL Server Configuration Manager, and navigating to SQL Server Network Configuration > Protocols for (Instance Name) and right-clicking on Named Pipes and selecting Properties. If Named Pipes is not enabled, be sure to enable it before restarting the SQL Server service (see comment by #NoahHeldman).
When connecting to the default instance (that is, without an instance name), SQL Server uses the default port of 1433 and the default pipe name of "\.\pipe\sql\query". Changing it back to match should (hopefully) fix it.
Those machines where the database connection as (local) doesn't work is probably that way because during the database installation, the instance name was set to something specific, rather than the default of "default instance". You can change these instance names, which may resolve this issue: http://coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/.
I think this occurs when you have SQL Server Express already installed and running, and then install SQL Server Developer Edition / Standard / etc....not 100% sure though, but from what I recall, that may be the case.