How to convert nvarchar to float in

Posted on 2012-09-07
Last Modified: 2012-09-07
Hello Experts,

I have the below query in application and it gives an error "Error converting varchar to float"

 SELECT  TOP 1 * FROM tblSystemEmployee WHERE Empid=" & Empid & " AND  CAST(CONVERT(VARCHAR(10),Salary,101) AS FLOAT) <" & Mp & " ORDER BY CAST(CONVERT(VARCHAR(10),Salary,101) AS FLOAT) DESC "

Open in new window

How do i resolve this?

Thank you!
Question by:developer2012
    LVL 49

    Accepted Solution

    Why are you converting salary to a varchar and then casting to a float?

    Author Closing Comment

    Thanks!. I went back and checked the database schema. There were changes in it and I don't need  that query any more. Thanks for your comment....provoked me to research...
    LVL 49

    Expert Comment

    by:Julian Hansen
    You are welcome - would be interested to know what the issue was but glad you got sorted.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Naughty Me. While I was changing the database name from DB1 to DB_PROD1 (yep it's not real database name ^v^), I changed the database name and notified my application fellows that I did it. They turn on the application, and everything is working. A …
    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now