Hello all,
Thanks for reading my thread,
let me brief you first. I have a table "Activity_id"
and in the table i have a column name "activity_id" nvarchar(6)
it just contains Serial No.s from 1 to 201.
Now the issue.
select max(activity_id) from activity_id
This query returns value "99" which is incorrect.
select max(cast(activity_id as int)) from activity_id
This query returns the value "201". which is correct.
I can reckon that its because of nvarchar and casting to int. but will u plz elaborate how nvarchar values are compared so that 99 is greater than 201.
Thanks,
Ahsan Ashfaq
Loading
Abhimanyu K VatsaPosted Jul 14, 2010, 1:59 AM
VARCHAR means Variable length character string and NVARCHAR means uNicode. NVARCHAR is nothing more than VARCHAR. NVARCHAR only support two-byte characters. And because of this cause you have to cast in in int or any else.
I think my post helped you, then please