Azure SQL Server IaaS: A quick approach to resolving collation conflict.

In this post I would like to highlight that approach that you can take to resolve the following error that you might get after restoring your on-prem SQL Server database(s) to Azure SQL Server IaaS: Cannot resolve the collation conflict between

We were getting the error because the Azure IaaS SQL Server default collation is: SQL_Latin1_General_CP1_CI_AS. Our on-prem default is Latin1_General_CP1_CI_AS. And our SQL code wasn’t setting an explicit collation for joins between temp tables and physical database table for character columns.

For the UK SQL Server install the server collation default is Latin1_General_CP1_CI_AS when the windows host language and location are set as English United kingdom.

We also didn’t have time to go through all our SQL code to find where we need to add explicit collation. The decision was to change SQL Server default collation to Latin1_General_CP1_CI_AS

To set the SQL Server collation to default can be done using this command on the Azure VM:

.\ C:\SQLServerFull\Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLServer /SQLSYSADMINACCOUNTS= "$env:COMPUTERNAME\<Windows Admin account>" /SAPWD="<Password>" /SQLCOLLATION=Latin1_General_CI_AS (or the collcation that suits your needs)

as the Azure SQL Server IaaS template leaves the full set-up files on the server under the C:\SQLServerFull.

After the above command complete there are extra server principals required for Azure SQL Server IaaS to integration into Azure. The following SQL Script creates the extra required server principals and the permissions needed:

CREATE LOGIN [NT Service\SQLIaaSExtensionQuery] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
 
ALTER SERVER ROLE [sysadmin] ADD MEMBER [NT Service\SQLIaaSExtensionQuery]
GO
 
CREATE LOGIN [NT SERVICE\SQLTELEMETRY] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
 
GRANT ALTER ANY EVENT SESSION TO [NT SERVICE\SQLTELEMETRY] AS [sa]
GRANT CONNECT ANY DATABASE TO [NT SERVICE\SQLTELEMETRY] AS [sa]
GRANT CONNECT SQL TO [NT SERVICE\SQLTELEMETRY] AS [sa]
GRANT VIEW ANY DEFINITION TO [NT SERVICE\SQLTELEMETRY] AS [sa]
GRANT VIEW SERVER STATE TO [NT SERVICE\SQLTELEMETRY] AS [sa]

Comments

Popular posts from this blog

Azure SQL Server IaaS SSIS: A required privilege is not held by the client

SSIS File handle leak in For Each Loop

Cannot update a database that has been registered as a data-tier application