Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Msg 245, Level 16, State 1, Line 10. Conversion failed when converting the varchar value 'PAULBUDGET ' to data type int. Expand / Collapse
Author
Message
Posted Thursday, July 30, 2009 6:16 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, November 08, 2009 3:51 PM
Points: 87, Visits: 98
Hi there!!
I get this error message:
Msg 245, Level 16, State 1, Line 10
Conversion failed when converting the varchar value 'PAULBUDGET ' to data type int.

I don't know why because I did a cast to varchar.
Can someone please help. Thanks.

Line 10 is the first field in the select statement.

SELECT cast(a.WS_Job_Number as varchar),
a.Year1,
a.PeriodID,
CASE
WHEN a.PeriodID = 1 THEN 'July'
WHEN a.PeriodID = 2 THEN 'August'
WHEN a.PeriodID = 3 THEN 'September'
WHEN a.PeriodID = 4 THEN 'October'
WHEN a.PeriodID = 5 THEN 'November'
WHEN a.PeriodID = 6 THEN 'December'
WHEN a.PeriodID = 7 THEN 'January'
WHEN a.PeriodID = 8 THEN 'February'
WHEN a.PeriodID = 9 THEN 'March'
WHEN a.PeriodID = 10 THEN 'April'
WHEN a.PeriodID = 11 THEN 'May'
WHEN a.PeriodID = 12 THEN 'June'
END AS 'Month',
b.Cost_Element_Desc,
rtrim(a.Cost_Code_Number_1) + rtrim(a.Cost_Code_Number_2) +
rtrim(a.Cost_Code_Number_3) + rtrim(a.Cost_Code_Number_4) as Cost_Code,
c.Cost_Code_Description,
a.Cost_Code_Actual_Cost,
a.Actual_Units_TTD,
a.Revsd_Forecast_Cost,
a.Revsd_Forecast_Units
FROM JC20002 a
inner join JC40209 b on a.Cost_Element = b.Cost_Element
left join JC40202 c on a.Cost_Code_Number_1 = c.Cost_Code_Number_1
and a.Cost_Code_Number_2 = c.Cost_Code_Number_2
and a.Cost_Code_Number_3 = c.Cost_Code_Number_3
and a.Cost_Code_Number_4 = c.Cost_Code_Number_4
and a.Cost_Element = c.Cost_Element
where WS_Job_Number = 1001
and Year1 = 2017
and PeriodID = 4
order by 1,2,3,6
Post #762858
Posted Thursday, July 30, 2009 8:19 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:55 AM
Points: 1,520, Visits: 3,035
Here's a shoot-from-the-hip response first: You can get this sort of error by specifying a numeric value for comparison with a character type column in the WHERE clause. If most of the values in that column of the table look like numbers, the query may work up to the point where it hits the row with a non-numeric value. Check the datatypes for the columns in your WHERE clause -- it looks as though WS-Job-Number is a char or varchar datatype already and that "PAULBUDGET" is in one of the rows in that column. The cast in the SELECT part doesn't affect the WHERE clause; that part can probably be fixed by putting the target value in quotes:
where WS_Job_Number = '1001'

If that's not it, then please post the DDL for the three tables involved to give someone a better shot at figuring out what the trouble really is.
Post #762870
Posted Thursday, July 30, 2009 9:13 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Sunday, November 08, 2009 3:51 PM
Points: 87, Visits: 98
Hi. Thanks.

That worked perfectly!!!
Post #762877
Posted Wednesday, January 15, 2014 6:43 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 2:21 AM
Points: 34, Visits: 43
Hi Can anyone please help me, I get the following error message:

Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value 'TA1001F ' to data type int.

But my one column is char and the other one is varchar.

How can I get this error about int then?
Post #1531079
Posted Friday, January 17, 2014 2:20 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, January 21, 2014 8:55 AM
Points: 1,520, Visits: 3,035
Hi JohnDean, and welcome to SS Central.

You should post this question along with a bit more detail (table structure and the failing query) as a new post in an appropriate forum. Click Forums over on the left side, and drill down to one that fits your version of SQL Server and kind of question, which is apparently "T-SQL".

You'll have a much better chance of getting help that way.
Post #1532283
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse