简体   繁体   中英

Rename server name in SQL Server 2014 and management studio?

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  

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM