I want to compare decimal data type in SQL sever 2005 stored procedure. My parameters are varchar(50) type. So I cast it to decimal(18,2). and then compare the two to see if one is bigger then the other. But for -ve numbers it does not work.
If I compare Field1(-1040.78) >= field2(456.47), it still returns true, obviously, field one is smaller! How do I handle it? Attached is the sample code. Please advise. Appreciate your prompt reply.
set @FieldOne = (select (cast(@FieldOne as decimal(18,2))) as 'Converted')
set @FieldTwo = (select (cast(@FieldTwo as decimal(18,2))) as 'Converted')
If @Opoeration = '>='
If @FieldOne >= @FieldTwo set @ReturnVal =1