Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Help

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-03-23 : 15:43:20
I am planning to move the few user databases from one server to new server.
I need to create plan for moving the databases and also i need the steps to move the databases.

Please help..

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-23 : 16:02:45
1. Backup Each Database
2. Verify Backups are good
3. Robocopy backups to new server
4. Restore the database
5. Fix the logins and User



USE [DBA]
GO


DBCC CHECKDB ('<dbname>')


BACKUP DATABASE [ISRS]
TO DISK = N'\\<unc path>\<dbname>_<datetime>.BAK'
WITH NOFORMAT, INIT, NAME = N'ISRS UAT-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO

-- Run This next block through the Verify

DECLARE @backupSetId int

SELECT @backupSetId = position
FROM msdb..backupset
WHERE database_name=N'<dbname>'
AND backup_set_id=(select max(backup_set_id) from msdb..backupset where database_name=N'<dbname>' )

IF @backupSetId is null
BEGIN
raiserror(N'Verify failed. Backup information for database ''<dbname>'' not found.', 16, 1)
END

RESTORE VERIFYONLY
FROM DISK = N'\\<unc path>\<dbname>_<datetime>.BAK'
WITH FILE = @backupSetId, NOUNLOAD, NOREWIND
GO


-- Run this to test the back up. Once the Backup Verify is restored, go check the verify database

-- Check for logical file names and locations

RESTORE FILELISTONLY
FROM DISK = N'\\<unc path>\<dbname>_<datetime>.BAK'
GO


-- If anyone is in Verify, Kick them out

USE [master]
GO

ALTER DATABASE <dbname>_VERIFY SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

-- Restore Database to Verify

RESTORE DATABASE <dbname>_VERIFY
FROM DISK = N'\\<unc path>\<dbname>_<datetime>.BAK'
WITH MOVE '<dbname>' TO '\\<unc db fp>\<dbname>_VERIFY.MDF'
, MOVE '<dbname>_LOG' TO '\\<unc db fp>\<dbname>_VERIFY.LDF'
, REPLACE
GO

-- Put the database into Multi user and read write mode

ALTER DATABASE <dbname>_VERIFY SET READ_WRITE
ALTER DATABASE <dbname_VERIFY SET MULTI_USER
GO







Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2012-03-28 : 15:14:42
Thanks Brett !

How to Fix the logins and User after DB restore and how to attach the associated jobs for the databases..
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-03-28 : 15:44:04
http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/

and you need to script out the jobs on the original server and compile them on the new server

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page
   

- Advertisement -