me a little bit confused too, what's the difference between this Question, and the one 2 days ago?
Second question of day: what is the len of @c?
declare @c varchar(800)
set @c = N'hello' + replicate('-',800)
Sorry - you were wrong
Correct answer: 800
The CAST to nvarchar(800) has a maximum 4000 character len. The CAST then to varchar(800) fits in that space, so the len is 800
2 days ago
SQLServerNewbieMCITP: Database Administrator SQL Server 2005
First question of day: what is the len of @c?
declare @c varchar(8000)
set @c = N'hello' + replicate('-',8000)
You got it right!
Correct answer: 4000
The CAST to NVARCHAR(4000) means that the maximum len is 4000, then the cast to varchar(8000) allows more characters, but the string is already truncated.