My table contains a field password whose size is Varchar(70). But when I enter the hash value of the password which is of size 40 the last few characters are getting truncated. I'm using SQL SERVER 2005. Why is it so??
+1
A:
The only time I've seen this is when you cast to varchar without specifying a length
Run this :
declare @test varchar(70)
set @test = '1111111111222222222233333333334444444444555555555566666666667777777777'
select @test
select
cast(@test as varchar) as CastedWithoutLength,
cast(@test as varchar(40)) as CastedWith40Length,
cast(@test as varchar(70)) as CastedWith70Length
CastedWithoutLength will only be 30 characters long, the rest will be whatever the length was set to.
Gordon Tucker
2009-10-13 18:42:00