In my table I have a column(Varchar). It contains values like 'abc^1234567^xyz'. I need to select part of the value and convert it to select the number and convert it to a decimal number and compare this number to a number from another table by joining two tables. So far I get error while want to convert it from varchar to decimal.
Here is my error message: Msg 8114, Level 16, State 5, Line 1 Error converting data type varchar to numeric. Here is my code:
SELECT
a.Status,
Cast(SUBSTRING(sourceNatKey, LEN(sourceNatKey)-11,7) As Decimal(18,4)),
b.caseId
FROM AGREEMENT_STATUS a
INNER JOIN APPLICATION_FACT b
ON
Cast(SUBSTRING(sourceNatKey, LEN(sourceNatKey)-11,7) As decimal(18,4)) =
b.caseId