I'm trying to pull data from couple of tables using a inner join. I have to use substring to get the request id part from a varchar field and then use convert function to convert to int
Below is my query and have been getting an error
SELECT RR.Requestid,RR.Rdate,RR.EDate ,REL.Requestid,Convert(INT,substring(REL.Itext,30,6)) from report_request RR inner join request_event_log REL on RR.Requestid = Convert(INT,substring(REL.Itext,30,6)) Where REL.EVentTypeid = 50
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'm28324' to data type int.
The same convert works ok in the below Query
SELECT Requestid,Convert(INT,substring(Itext,30,6)) as OrigRequestid from requesteventlog where requestid = 560813 and eventtypeid =50
How should I proceed with my problematic Query?
Thanks in Advance