Sunday, 14 December 2008

How to upgrade database from SQL Server 2005 to SQL Server 2008

The following steps should be carried out upgrade a database from SQL Server 2005 to SQL Server 2008

Step 1:
Detach the database files from SQL Server 2005 and attach to SQL Server 2008 Server

Step 2:
Execute the below command to update the index and table Statistics in the newly attached database
SP_UPDATESTATS
It is recommended to execute update statistics separately for each table with full scan as given below
UPDATE STATISTICS . WITH FULLSCAN, NORECOMPUTE


Step 3:
Execute the below command to rest all the counters DBCC UPDATEUSAGE('')

Step 4:
Change the Database Compatibility Level as specified
Go to Database Properties à Options à Compatibility Level to à SQL Server 2008(100)