Error converting data type varchar to float.

Analyst_SQL 3,551 Reputation points
2021-07-01T10:10:01.537+00:00

Below is query,

SELECT sum(isnull(Convert( float,Rec.Sell_Amt ),0))-sum(isnull(convert(float ,Pr.Rec_Amt ),0))as Amt,Pr.Level_Four_ID
FROM     tbl_Receivable_Customer AS Rec
left outer join tbl_Received_Amount Pr 
on Pr.Sell_ID=Rec.Sell_ID

where rec.Sell_Del is null and pr.Sell_Del is null

group by pr.Level_Four_ID
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,856 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,559 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tomáš Zíka 256 Reputation points
    2021-07-01T10:44:52.793+00:00

    What is the error (number and message)?
    We don't have access to your table definitions and data, so we cannot replicate the issue.

    My guess is that the varchar column container other than numeric data.
    You can find them by using

    WHERE TRY_CAST([yourVarcharCol] as float) IS NULL  
    

    TRY_CAST documentation:
    https://learn.microsoft.com/en-us/sql/t-sql/functions/try-cast-transact-sql?view=sql-server-ver15

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful