I have an OPENJSON command that takes the parsed JSON and LEFT joins it onto an existing table.
When I add the LEFT JOIN I get the error:
collation conflict between "Latin1_General_BIN2" and "SQL_Latin1_General_CP1_CI_AS"
The table has the same collation for all string columns as: SQL_Latin1_General_CP1_CI_AS
I've tried adding COLLATE DATABASE_DEFAULT in the LEFT JOIN, but with no improvement.
The query I'm using is roughly as:
DECLARE @json NVARCHAR(MAX) = '
{
"ExampleJson": {
"stuff": [
{
"_program_id": "hello",
"work_date": "2021-03-23 00:00:00"
}
]
}
}';
SELECT *
FROM
OPENJSON
(
(
@json
), '$.ExampleJson.stuff'
)
WITH (
[program_id] NVARCHAR(255) '$."program_id"'
,[work_date] DATETIME '$."work_date"'
) [json_data]
LEFT JOIN
[existing_db_data]
ON [existing_db_data].[program_id] = [json_data].[program_id]