Link to home
Start Free TrialLog in
Avatar of MARefresh
MARefresh

asked on

Error Converting nvarchar to int?

I am trying to convert the varchar value 0.33 to an int for a Reporting Services report and get the following error message:

Reporting Services Error
--------------------------------------------------------------------------------
 
An error has occurred during report processing. (rsProcessingAborted) Get Online Help
Query execution failed for data set 'MyDB'. (rsErrorExecutingCommand) Get Online Help
Syntax error converting the varchar value '0.33' to a column of data type int.

I am using temporary tables and stored procedures to populate and retrieve the data.  Does anyone know why this conversion/cast is not allowed?

Thanks.
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

why dont you try Float instead of int

Convert(Float, Field_Name)
Avatar of MARefresh
MARefresh

ASKER

I will try that.  Thanks.  Basically I am converting the varchar (0.33) to int to compare to 3 different ranges of values:

SET @wk_WhereClauseHigh            = ' CONVERT(int, Priority) BETWEEN 0 AND 11 '
SET @wk_WhereClauseMedium       = ' CONVERT(int, Priority)  BETWEEN 12 AND 23 '
SET @wk_WhereClauseLow             = ' CONVERT(int, Priority)  BETWEEN 24 AND 36 '

If it falls between 0 and 11 it is considered 'High'... and so forth... that is why int made sense.

Any thoughts?
You can use ROUND

Convert(int, Round(yourfieldname, 1)

Round returns a numeric expression, rounded to the specified length or precision
Missed a ')' in my previous post

Convert(int, Round(yourfieldname, 1))
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial