开发者

SQL Server 2000 to SQL Server 2008 R2 migration

开发者 https://www.devze.com 2023-03-15 02:04 出处:网络
I am using SQL Server 2000 including 77 databases, and I want to migrate them to the new SQL Server 2008 R2.

I am using SQL Server 2000 including 77 databases, and I want to migrate them to the new SQL Server 2008 R2.

开发者_运维知识库

I can do this operation individually with attach or restore commands. Is there any script for migrating 77 databases to the new server installed SQL Server 2008 R2.

Thank you


You could write a script to backup in a loop and restore on another server

As long as the backup files are visible to both servers. This would allow a WITH MOVE option to allow for different drives/folders.

Backups are smaller than MDFs/LDFs too to less copying


You will need to produce your own script as you would really want to do more than backup and restore. Other things you might like to do is run DBCC UpdateUsage, set the compatibility level, update the stats, run DBCC CheckDB with Data_Purity, change the page verify option to checksum. You may have replication and full text catalogues to deal with as well. All these things would probably need to go into your script.

You would need to setup a script that performs all/some/more of the things mentionned previously on a database and then extend your script to loop through all your databases. This can be done using a combination of batch files or powershell files and utilizing sqlcmd.

For example this is one script I run after restoring the backups onto the new server. This is called from a windows batch file via sqlcmd.

USE [master]

GO

ALTER DATABASE [$(DATABASENAME)] SET COMPATIBILITY_LEVEL = 100

ALTER DATABASE [$(DATABASENAME)] SET PAGE_VERIFY CHECKSUM WITH NO_WAIT GO

Use [$(DATABASENAME)]

Go Declare @DBO sysname

--who is the sa user

Select @DBO = name from sys.server_principals Where principal_id = 1

--assign sa the DB owner

exec ('sp_changedbowner ''' + @DBO +'''') go

--fix the counts

dbcc updateusage (0) go --check the db include the column value integrity

dbcc checkdb(0) With Data_Purity, ALL_ERRORMSGS, NO_INFOMSGS go

--make sure the stats are up to date

exec sp_updatestats

Go


You could use a software tool like Sql Compare.

Failing that I would script them individually.

You could run round the internal sysobjects table and build a combined script, but I wouldn't.

0

精彩评论

暂无评论...
验证码 换一张
取 消