sp_executesql is not working when sql server is running in a container

Yeturu Jagadeesh Reddy 0 Reputation points
2025-04-28T04:24:18.5333333+00:00

sp_executesql is not working when sql server is running in a container. The issue only happens when I specify collation as Latin1_General_BIN

docker command:

docker run -d -p 1433:1433 -e 'ACCEPT_EULA=Y' -e "MSSQL_SA_PASSWORD=$db_password" -e "MSSQL_COLLATION=Latin1_General_BIN" --name database mcr.microsoft.com/mssql/server:latest

reproduce query:


declare @sql nvarchar(MAX) = 'select @@version'
exec sp_executesql @sql

SQL Server Database Engine
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.