In this article I will explain how to change the collation for your production Azure SQL Databases without loosing data/updates on the database with a minimum downtime.
Steps in brief:
Things to consider:
Steps in details:
1. Make sure you have a modern version of SQLPackage.
2. Start the maintenance window for your application.
3. Make a copy of the production database to a higher service tier ex: P11.
How to copy SQL databases: https://docs.microsoft.com/en-us/azure/azure-sql/database/database-copy?tabs=azure-powershell#copy-u...
4. Export the copied database using SQLPackage from a VM on the same region of your SQL server.
sqlpackage.exe /Action:Export /ssn:tcp:<ServerName>.database.windows.net,1433 /sdn:<DatabaseName> /su:<UserName> /sp:<Password> /tf:<TargetFile> /p:Storage=File
5. Change the database collation in the bacpac model.xml file:
For example:
From: <Property Name="Collation" Value="SQL_Latin1_General_CP1_CI_AS" />
To: <Property Name="Collation" Value="Hebrew_CI_AS" />
6. Run the import using sqlpackage.exe, and use the /ModelFilePath:C:\Temp\model.xml parameter to override the model.xml in the .bacpac.
For example:
sqlpackage.exe /Action:Import /tsn:<server>.database.windows.net /tdn:<database> /tu:<user> /tp:<password> /sf:"C:\Temp\database.bacpac" /ModelFilePath:C:\Temp\model.xml /p:DatabaseEdition=Premium /p:DatabaseServiceObjective=P11
7. When the import operation completed, Change the database name, or modify the application connection string to use the new database.
8. Stop the maintenance window for your application and run workload.
9. Delete the copied and old databases.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.