Evgeny - Monday, December 11, 2017 7:06 PM
No, my servers are SQL_Latin1_General_CP1_CI_AS as well. If I were to guess, I'd say it's a string component interpreting CHAR(0) as a string terminator rather than testing the length of the string. What confuses me is that behavior should not change that much between versions, which is why I'm looking for a configuration difference.
The varbinary results show that the full 12 characters are still there. I wonder what you'd get with:
declare @a varchar(6) = 'ABCDEF'
--select cast(cast(@A as nvarchar(12)) as varbinary(12))
select cast(cast(cast(cast(@A as nvarchar(12)) as varbinary(12)) as varchar(12)) as varbinary(12))
That might show if the cast to varchar is truncating the results or not.