Welcome to SQLDBcontrol Forums Sign in | Join | Help
in

Moving a database

Last post 11-09-2009, 19:00 by ddriver. 5 replies.
Sort Posts: Previous Next
  •  11-05-2009, 21:21 308

    Moving a database

    We are about to start reorganizing our servers. What do I need to do so that when a database is moved form one server to another we do not lose our version control history?

    Also we have databases that are named the same thing on multiple servers that only contain a few replicated tables. Would that confuse things some?

    Thanks!
  •  11-05-2009, 22:53 311 in reply to 308

    Re: Moving a database

    There is currently no functionality within the application that would allow you to do this.

    However, if it's the only database on the server that you have in source control you could rename the server in SQLDBControl.

    This not being the case however, it should only just involve updating some tables within the source control database so it wouldn't be a problem for us to create some T-SQL that would allow you to do this relatively easily.

    Depending on how long you have before you perform the move we could include this functionality within the next build.

    With regards to having the same database names on multiple servers, I'm not sure I understand.

    Are you saying that you want to move a database to a server that already has a database with the same name on it? If so, would the intention be to merge the objects in the two databases together?
    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  11-06-2009, 15:06 314 in reply to 311

    Re: Moving a database

    Moving a database between servers is a big task so it is going to take several weeks to prepare. If the best alternative is a SQL script I would be OK with that.

    As far at the two databases with the same name but on different servers goes, we are only going to move one of them and it isn't going to be moved to the same server that the other one is one. They will still be on different servers.
  •  11-06-2009, 16:02 317 in reply to 314

    Re: Moving a database

    In that case it shouldn't really be a problem that there are two databases with the same name on different servers.

    We'll provide you with a script that will enable you to move the database to a different server next week.


    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  11-09-2009, 9:34 321 in reply to 317

    Re: Moving a database

    Attachment: MoveDatabase.txt

    The attached file contains a script that creates a stored procedure called MoveDatabase, that will enable you to logically move a database and its objects to another server.  Create the stored procedure in the source control database.

    Naturally, the destination server needs to exist first so you'll need to add the server to the project if it isn't already part of it.  Once that's done you can execute the following script, remembering to enter the correct values for the 4 parameters near the top.

    Although I doubt its necessary as the procedure is pretty straight forward it's always a good idea to backup the source control database if you don't already do it regularly.

    declare @current_server_db_id int;
    declare @destination_server_id int;
    declare @current_server varchar(128);
    declare @database varchar(128);
    declare @project varchar(128);
    declare @destination_server varchar(128);

    select @current_server = '<enter current server name>'
      , @database = '<enter database name>'
      , @project = '<enter project name>'
      , @destination_server = '<enter destination server>'

    select @current_server_db_id = ServerDbId
    from ProjectServerDatabase psd
     join ProjectServer ps on ps.ProjectServerId = psd.ProjectServerId
    where ServerName = @current_server
    and DatabaseName = @database
    and ProjectName = @project

    select @destination_server_id = ProjectServerId
    from ProjectServer
    where ServerName = @destination_server
    and ProjectName = @project

    exec MoveDatabase @current_server_db_id, @destination_server_id


    SQLDBcontrol Support

    support@sqldbcontrol.com
  •  11-09-2009, 19:00 322 in reply to 321

    Re: Moving a database

    Looks to be just what we needed.

    Thanks!
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems