All T-SQL commands are well documented including the required permissions, for example the RESTORE command =>
SQL Server 2022 : Issue Restoring Database from 2014 Fails Without 'sysadmin' Role
We are attempting to restore a SQL Server 2014 database to SQL Server 2022. The process includes updating the database compatibility level from 120 (SQL 2014) to 160 (SQL 2022) after restoration.
The issue we are encountering is:
- The restore and compatibility level change work only when the user account has the
sysadmin
server role. - If the same account is used without
sysadmin
privileges, the restore fails or specific post-restore operations (e.g., compatibility level change or access to the database) do not work as expected.
What is the minimum required permission set (server role or specific database-level permissions) to perform the following:
- Restore a database
- Change compatibility level using
ALTER DATABASE
- Is there any official Microsoft documentation or KB article that outlines permission requirements for cross-version restore and compatibility level modification?
- Are there known changes in SQL Server 2022 security/permissions that might cause this behavior compared to previous versions? C# code used:
connection string used: "User ID=root;Password=root;Persist Security Info=True;Initial Catalog=master;Data Source=(local)\SQLEXPRESS"SQLString = @"USE master; ALTER DATABASE " + DBName + " SET SINGLE_USER WITH ROLLBACK IMMEDIATE;restore database " + DBName + " from disk = @FilePath with replace;ALTER DATABASE " + DBName + " SET MULTI_USER;"; SQLString += " ALTER DATABASE " + DBName + " SET COMPATIBILITY_LEVEL=160;";
SQL Server Migration Assistant
2 answers
Sort by: Most helpful
-
-
Erland Sommarskog 121.3K Reputation points MVP Volunteer Moderator
2025-06-12T17:32:40.31+00:00 To restore a database over an existing one (which you are doing), you need to be member of the sysadmin or dbcreator fixed roles, or you need to be the owner of the database.
To change the compatibility level of the database, you need to be member of the database role db_owner. Note that when you restore a database over an existing one, the owner of the database is retained. So if you only are in the dbcreator role, you may not be able to change the compatibility level after the restore.
Best practice is to explicitly set the owner after the restore, since else there may be a mismatch of what is recorded in the database and what is recorded in sys.databases.
All this does not require sysadmin, but the permissions needed are so hefty, that in practice it's better to run as sysadmin.