Vijay
asked on
T-SQL Scripts for DB migration
I am looking for scripts for below requirements:
1. How quickly attach 100+ databases in sql 2016?
2. How quickly change 100+ databases compatibility level (from 100 to 130) in sql 2016?
The exact requirement is that we are migrating sql server 2008 to 2016.
1. How quickly attach 100+ databases in sql 2016?
2. How quickly change 100+ databases compatibility level (from 100 to 130) in sql 2016?
The exact requirement is that we are migrating sql server 2008 to 2016.
Incidently, sp_attach_db is presumably now deprecated, use this instead:
https://docs.microsoft.com/en-us/sql/relational-databases/databases/attach-a-database
https://docs.microsoft.com/en-us/sql/relational-databases/databases/attach-a-database
declare @dynamicSQL nvarchar(max) = '';
select @dynamicSQL += 'alter database [' + [name] + ']
set compatibility_level = 130;
'
from sys.databases
where 1 = 1
and [database_id] > 4
select @dynamicSQL;
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Venkat.
Open in new window