Create and run a SQL Server migration job containing metadata with an EXECUTE AS clause
Stay organized with collections
Save and categorize content based on your preferences.
Overview
A SQL Server migration job
doesn't migrate database user and server login data. Therefore,
sources which contain objects defined by users with the EXECUTE AS '[database_user_name]' clause won't be migrated to the new Cloud SQL replica, because the users don't yet
exist there. As a result, the overall migration process will fail.
For example:
CREATE OR ALTER PROCEDURE dbo.example
WITH EXECUTE AS 'some_user'
AS BEGIN
…
END
This stored procedure won't be migrated because the some_user user can't be migrated. This is because the user doesn't exist on the target database.
To identify which objects are using the EXECUTE AS '[database_user_name]' clause in your source database, use these queries and
check if there are users for them in the destination database.
To run a migration job from a source which includes such metadata, create the users on your destination Cloud SQL instance before starting your migration job.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[[["SQL Server migration jobs do not migrate database user and server login data, which can lead to migration failures."],["Objects defined with the `EXECUTE AS '[database_user_name]'` clause in the source database will not be migrated if the specified user does not exist in the destination."],["The provided SQL query helps identify objects in the source database that use the `EXECUTE AS '[database_user_name]'` clause."],["To ensure a successful migration, users referenced in the `EXECUTE AS` clause must be created on the destination Cloud SQL instance before starting the migration job."]]],[]]