Posted On November 3, 2020

How to Migrate a Database to a Newer Version of Microsoft SQL Server

kimconnect 0 comments
blog.KimConnect.com >> Database >> How to Migrate a Database to a Newer Version of Microsoft SQL Server
Get Version of new SQL server

Create a sql-dump script on the old SQL server:

Run SQL Management Studio (“C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\Ssms.exe”) > right-click DB > Tasks > Generate Scripts

Choose Objects > ‘Script entire database and all database objects’ > Next > Advanced

Target the correct database version

Set SQL Server version to match the target > Types of data to script option=Schema and data > Script Logins=True > Script Full-Text Indexes=True > Script Triggers=True > OK > Next > Next > Finish

Execute Script on New Server:

Fix Database paths before execution:

USE [master]
GO
/****** Object: Database [testDb] Script Date: 11/3/2018 5:10:13 PM ******/
CREATE DATABASE [testDb]
CONTAINMENT = NONE
ON PRIMARY
( NAME = N'testDb', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\testDb.mdf' , SIZE = 598016KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB )
LOG ON
( NAME = N'testDb_log', FILENAME = N'D:\Program Files\Microsoft SQL Server\MSSQL13.MSSQLSERVER\MSSQL\Data\testDb.ldf' , SIZE = 73728KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB )
GO
ALTER DATABASE [testDb] SET COMPATIBILITY_LEVEL = 130
GO

Use PowerShell to invoke SQL Query:

Invoke-Sqlcmd -InputFile "B:\Backups\testDb.sql" | Out-File -FilePath "B:\Backups\testDb.rpt"

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Post

SQL Error Msg 3201, Level 16, State 2

Sample Error Message: Msg 3201, Level 16, State 2, Line 2Cannot open backup device '\\1.1.1.1\d$\backup\TEST_MSCRM.bak'.…

SQL Server Overview

SQL Buffer Manager (Cache) 8K Pages between memory and disk storage 8 Pages = 1…

SQL: Creating a Storage Report of Databases Residing within Server

Method 1: -- Get sizes of all databases from system (not real-time) WITH fs AS…
Other project: DragonCoin.com