Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 help me....

Author  Topic 

ejoeyz_85
Yak Posting Veteran

54 Posts

Posted - 2008-01-12 : 18:40:18
below is my sql query statement... hope u understand

SELECT u.User_fname, pv.PV_address, p.Start_monitoring, p.Last_monitoring, p.Period_of_monitoring, m.Ongoing_maintenance,
m.Savings_for_inverter_replacement, m.Monitoring, m.Total_anual_maint_and_monitor
FROM PerformanceData p, MonitoringCost m, Photovoltaic pv, Users u
WHERE p.Performance_id=m.MonitoringCost_id and
pv.PV_id=p.Performance_id and
pv.PV_id=m.MonitoringCost_id and
u.User_id =p.Performance_id and
u.User_id =pv.PV_id and
u.User_id = m.MonitoringCost_id



when i execute this query, it cannot executed because i got this error message...

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


what should i do??

jonathant
Starting Member

6 Posts

Posted - 2008-01-12 : 19:14:53
quote:
Originally posted by ejoeyz_85

below is my sql query statement... hope u understand

SELECT u.User_fname, pv.PV_address, p.Start_monitoring, p.Last_monitoring, p.Period_of_monitoring, m.Ongoing_maintenance,
m.Savings_for_inverter_replacement, m.Monitoring, m.Total_anual_maint_and_monitor
FROM PerformanceData p, MonitoringCost m, Photovoltaic pv, Users u
WHERE p.Performance_id=m.MonitoringCost_id and
pv.PV_id=p.Performance_id and
pv.PV_id=m.MonitoringCost_id and
u.User_id =p.Performance_id and
u.User_id =pv.PV_id and
u.User_id = m.MonitoringCost_id



when i execute this query, it cannot executed because i got this error message...

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


what should i do??



Two of the columns that you are joining are different data types. The value in the varchar field "ejoy" can't be converted to an integer for comparison.



Jonathan
Go to Top of Page

ejoeyz_85
Yak Posting Veteran

54 Posts

Posted - 2008-01-12 : 19:26:40
how to convert varchar to int?
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2008-01-12 : 19:46:26
Use convert function if varchar column has numbers only.
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2008-01-12 : 20:10:44
The statement you posted doesn't contain any reference to a column called [ejoy]. The error must be from a different statement. Perhaps one of your tables is really a VIEW?

Be One with the Optimizer
TG
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-01-13 : 01:55:36
Duplicate post
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=95422



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -