none
Renaming the Computer and SQL Server in the same batch script RRS feed

  • Question

  • I am trying to rename a computer using XP and also rename SQL server in the same script.  My concern is as follows: What is the best practice for renaming the computer and a SQL server?  Is it save to create a batch file that does both and then restart the computer or separate them both with a restart?.

    Thank you

    Thursday, April 19, 2012 6:07 PM

Answers

  • Hi Mangual43,

    Regarding to your description, instances name can not be renamed and changed.

    If you want to change computer name that is running SQL Server you can connect to SQL Server using the new computer name after you have restarted the server. However, to correct the sysservers system table, you should manually run these procedures:
    sp_dropserver old_name
    GO
    sp_addserver new_name, local
    GO

    When you have more than one instance of SQL Server on the computer, change the sysservers system table information by running the stored procedures this way:
    sp_dropserver old_servername\instancename
    GO
    sp_addserver new_servername\instancename, local
    GO

    For more information, please refer to Rename a Computer that Hosts a Stand-Alone Instance of SQL Server:
    http://msdn.microsoft.com/en-us/library/ms143799.aspx


    Regards, Amber zhang

    Friday, April 20, 2012 7:45 AM
    Moderator
  • hi, please go through the below link, it may help you.
    • Marked as answer by Mangual43 Friday, April 20, 2012 7:07 PM
    Friday, April 20, 2012 11:49 AM

All replies

  • if you rename a computer you've to tell it to SQL Server by dropping server and adding it adding with the new name:

    sp_dropserver <old_name>
    GO
    sp_addserver <new_name>, local
    GO
         

    see description Rename a Computer that Hosts a Stand-Alone Instance of SQL Server

    Thursday, April 19, 2012 6:35 PM
  • I am aware of how to drop my server name and add new one.  My question is, as far as best practice goes, is it ok to do it at the same time I am renaming my computer before restart.  Or, do I need to change the computer name first, restart my computer,  and then rename the SQL server? if so, Why or Why not?



    • Edited by Mangual43 Thursday, April 19, 2012 7:02 PM
    Thursday, April 19, 2012 6:57 PM
  • Hi Mangual43,

    Regarding to your description, instances name can not be renamed and changed.

    If you want to change computer name that is running SQL Server you can connect to SQL Server using the new computer name after you have restarted the server. However, to correct the sysservers system table, you should manually run these procedures:
    sp_dropserver old_name
    GO
    sp_addserver new_name, local
    GO

    When you have more than one instance of SQL Server on the computer, change the sysservers system table information by running the stored procedures this way:
    sp_dropserver old_servername\instancename
    GO
    sp_addserver new_servername\instancename, local
    GO

    For more information, please refer to Rename a Computer that Hosts a Stand-Alone Instance of SQL Server:
    http://msdn.microsoft.com/en-us/library/ms143799.aspx


    Regards, Amber zhang

    Friday, April 20, 2012 7:45 AM
    Moderator
  • hi, please go through the below link, it may help you.
    • Marked as answer by Mangual43 Friday, April 20, 2012 7:07 PM
    Friday, April 20, 2012 11:49 AM
  • please chek the below link....

    http://simplystallings.com/blog/renaming-20082008r2-sql-instance-after-sysprep

    Friday, April 20, 2012 11:52 AM