Deploying memory-optimized objects
Published 13 December 2022
When you deploy a database containing memory-optimized objects (ie memory-optimized tables, natively compiled stored procedures and memory-optimized table types) with SQL Compare, we recommend you run two deployments:
- Deploy the memory-optimized objects without transactions
- Deploy the remaining objects with transactions
If you don't run two deployments, you might lose data if the deployment script fails. This is because memory-optimized objects can't be deployed inside a transaction. If a deployment script doesn't use transactions and the script fails, it won't be rolled back and you could lose data. If you perform two deployments, only the memory-optimized objects are deployed outside a transaction, so you're less likely to lose data.
Example
1. Deploy the memory-optimized objects without transactions
- In SQL Compare, specify your source and target databases.
In this example, WidgetStaging is our source database and WidgetProduction is our target database. - In Options, select Don't use transactions in deployment scripts:
- Run the comparison.
- In the comparison results, select the memory-optimized objects for deployment.
In this example, WidgetStaging includes two memory-optimized tables, ShoppingCart and UserSession, and a natively compiled stored procedure, usp_AssignCart: Start the deployment wizard.
Make sure the Create a deployment script deployment method is selected.
When you deploy without transactions, we recommend you back up the target database before you deploy. For more information, see Backing up before deployment.
Finish the deployment wizard to open the deployment script in Management Studio.
If the deployment includes memory-optimized tables or natively compiled stored procedures, any associated server DDL triggers and server event notifications need to be dropped and recreated. SQL Compare doesn't support server level objects, so you need to manually edit the script to include the SQL to drop and recreate them.
- Run the script to deploy the objects.
2. Deploy the remaining objects with transactions
- In SQL Compare, click Edit Project.
- In Options, clear Don't use transactions in deployment scripts and click OK.
- Deploy all the objects.