Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change a Sql-Server (express) from a named instance to localhost?

Tags:

Is there a way to change a mssql express from a named instance to localhost?

When first installing the server I gave my mssql express server, a name. Now, working on a project where the web.config specifcs the localhost, or (local), I have to edit all of these before I migrate the db or run the application.

To connect to my database, I have to specify my instance instead of localhost like so: MyComputerName\Instance;Database=db_name;"

I would like to simply use: localhost;Database=db_name; This currently does not work.

I don't want to have to re-install mssql, however I have considered this an option if no other options are avaiable.

I am using "Microsoft SQL Server Express Edition with Advanced Services" version 10.50.2550.0

like image 401
Patrick Avatar asked Jun 24 '13 17:06

Patrick


People also ask

How do I change the instance name in SQL Express?

The process to change a SQL Server instance name has not changed from how it is done on a Windows based SQL Server. We need to drop the existing SQL Server instance name using system stored procedure sp_dropserver and then we need to add the new SQL Server instance name using system stored procedure sp_addserver.

Can we change named instance to default instance?

You can install SQL Server again and create a named instance. Show activity on this post. you can rename your instance but you can not change the named instance to default instance and vice versa.

How do I find the instance name of SQL Server Express?

Go to Start > Programs > Microsoft SQL Server > Configuration Tools. Locate the running MS SQL Server instance name (circled below in red).

Can I rename a SQL Server instance?

SQL Server does not support renaming computers that are involved in replication, except when you use log shipping with replication. The secondary computer in log shipping can be renamed if the primary computer is permanently lost.


1 Answers

If you don't specify an instance name when connecting to a server, it will look at port 1433.

By default, the MSSQLSERVER instance (i.e. the default) will be assigned this static port.

By default, any named instances will be assigned dynamic ports which are discovered using the SQL Server Browser service.

You might not be able to rename an instance, but you can change its port number.

For your named instance, you need to set it to the static default SQL Server port, i.e. 1433. Obviously TCP/IP will need to be enabled for the instance:

enter image description here

Once you've done this, should be able to connect to localhost without supplying a name as it will just try and connect to 1433.

like image 137
Ian Preston Avatar answered Oct 18 '22 13:10

Ian Preston