It’s actually a collation issue. I can resolve it by changing these lines:
CAST([type] collate database_default AS VARCHAR(255)) AS [type],
CAST(type_desc collate database_default AS VARCHAR(255)) AS type_desc,
CAST(create_date AS VARCHAR(255)) AS create_date,
CAST(lock_escalation_desc collate database_default AS VARCHAR(255)) AS lock_escalation_desc
The specific issue is that name
is collated as Latin1_General_CI_AS
, whereas the other 3 columns you mentioned are collated as Latin1_General_CI_AS_KS_WS
(At least, on my machine, I’m not sure what it would be like on a server/database with different default collation).