Simon Facer (5/27/2008)
The REPLICATE('-', 8000) has an implicit cast to NVARCHAR
Sorry Simon, this is not correct (or at least misleading).
The type conversion happens during the concatenation of the two strings.
-- Example 1:
-- Replicating a non-unicode string results in a non-unicode string
-- (Datalength = Lenght)
SELECT DATALENGTH(REPLICATE('-', 8000)), Len(REPLICATE('-', 8000))
-- Example 2: Concatenating a unicode string and
-- a non-unicode string results in a unicode string
-- (Datalength = 2* Lenght)
SELECT DATALENGTH(N'Unicode' + 'Nonunicode'), LEN(N'Unicode' + 'Nonunicode')
Best Regards,
Chris Büttner