Machine Name Change

  • I'm grossly ignorant of SQL Express, so please excuse me if this is obvious.

    If you change the machine name in SQL Server, the server, you will, in all likelihood have to reinstall the server. According to our support people, if they change the machine name with MSDE, they have to reimage the machine to get the database back online. The question is, does the same thing happen with SQL Express? If so, is there a good way to work around it, or does it require you to basically reinstall?

    Thanks for any help.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • The sp_dropserver/addserver doesn't work?

    I'd be surprised as this is the same codebase as the Workgroup/Standard/Enterprise versions.

  • You're talking to the wrong guy. I'm posting this for our tech support guys. Luckily, I don't have to muck about in Express (yet). I'll try it out & get back to you.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • That drops linked servers on a local machine. That's not going to help with Express is it?

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Actually I just did this yesterday, however, it was on SQL Server 2005 Standard edition. Not sure it applies to Express.

    I opened SQL Server Management Studio, created a new query then entered and ran the following:

    DECLARE @var1 nvarchar(50)

    DECLARE @var2 nvarchar(50)

    SET @var1 = convert(nvarchar(50),@@SERVERNAME)

    SET @var2 = convert(nvarchar(50),SERVERPROPERTY('MachineName'))

    EXEC sp_dropserver @var1

    EXEC sp_addserver @var2, local

    GO

  • Steve Jones - Editor (12/20/2007)


    The sp_dropserver/addserver doesn't work?

    I'd be surprised as this is the same codebase as the Workgroup/Standard/Enterprise versions.

    I agree. According to BoL the sp_addserver even allows for named instances. I suspect that this also worked with MSDE but I have not tried it myself.

  • DonaldW (12/21/2007)


    I agree. According to BoL the sp_addserver even allows for named instances. I suspect that this also worked with MSDE but I have not tried it myself.

    Proven - it works with MSDE. I did it myself multiple times.

  • Here is a batch file I wrote:

    SC CONFIG SQLBROWSER START= DEMAND

    NET START SQLBROWSER

    REM THIS WILL UPDATE THE INSTANCE NAME ON A CLIENT, WHERE THE PC NAME HAS BEEN CHANGED AFTER THE INSTALLATION OF SQL

    REM YOU SHOULD NOT BE USING DELIMINATORS (- SIGN) IN YOUR PC NAMES!!!! USE (_ UNDERSCORE) INSTEAD, OTHERWISE THIS SCRIPT WILL NOT WORK

    %SYSTEMDRIVE% SET

    "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\SQLCMD" -S "127.0.0.1\(yourinstanceifyouhaveone)" -Q "EXEC sp_dropserver @server = @@servername"

    "%ProgramFiles%\Microsoft SQL Server\90\Tools\Binn\SQLCMD" -S "127.0.0.1\(yourinstanceifyouhaveone)" -Q "EXEC sp_addserver %COMPUTERNAME%, 'local'"

    REM RESTARTING SERVICES FOR SQL SERVERNAME TO TAKE EFFECT

    NET STOP MSSQL$(yourinstanceifyouhaveone) /y

    NET STOP SQLSERVERAGENT /y

    NET STOP MSSQLSERVER /y

    NET START MSSQL$(yourinstanceifyouhaveone)

    NET START MSSQLSERVER

    NET START SQLSERVERAGENT

    REM ADDS A SHORT DELAY FOR SQL TO RESTART

    PING 127.0.0.1

    PING 127.0.0.1

    PING 127.0.0.1

    PING 127.0.0.1

    NET STOP SQLBROWSER

    You may have to modify the code if you're using an instance or not.

  • Looks good. Thanks.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply