Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Cast into Numeric

Cast into Numeric

Scheduled Pinned Locked Moved Database
helpdatabase
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    banker_kiran
    wrote on last edited by
    #1

    Hi, Problem with converting varchar into Numeric select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Convert(Numeric,Data_Value) > 10000 Value without where condition shows like. 1 2500 2 3500 3 5000 4 10000 5 15000 6 20000 but when i add Convert(Numeric,Data_Value) > 10000 in query then its give me an error. Error converting data type varchar to numeric.

    kiran banker

    R M 2 Replies Last reply
    0
    • B banker_kiran

      Hi, Problem with converting varchar into Numeric select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Convert(Numeric,Data_Value) > 10000 Value without where condition shows like. 1 2500 2 3500 3 5000 4 10000 5 15000 6 20000 but when i add Convert(Numeric,Data_Value) > 10000 in query then its give me an error. Error converting data type varchar to numeric.

      kiran banker

      R Offline
      R Offline
      r a j u u
      wrote on last edited by
      #2

      plz try this select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and val > 10000

      B R 2 Replies Last reply
      0
      • R r a j u u

        plz try this select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and val > 10000

        B Offline
        B Offline
        banker_kiran
        wrote on last edited by
        #3

        giving an error invalid column namd

        kiran banker

        1 Reply Last reply
        0
        • R r a j u u

          plz try this select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and val > 10000

          R Offline
          R Offline
          r a j u u
          wrote on last edited by
          #4

          select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Cast(Data_Value as Numeric)as Val > 10000

          B 1 Reply Last reply
          0
          • R r a j u u

            select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Cast(Data_Value as Numeric)as Val > 10000

            B Offline
            B Offline
            banker_kiran
            wrote on last edited by
            #5

            still no working but i write like this select DEFINITION_DETAIL_DATA.SMID, Convert(Decimal,Data_Value) as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 AND DEFINITION_DETAIL_DATA.SMID = 204 and Convert(Decimal,Data_Value) > 1 then it works but i want like this select DEFINITION_DETAIL_DATA.SMID, Convert(Decimal,Data_Value) as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Convert(Decimal,Data_Value) > 1

            kiran banker

            1 Reply Last reply
            0
            • B banker_kiran

              Hi, Problem with converting varchar into Numeric select DEFINITION_DETAIL_DATA.SMID, Cast(Data_Value as Numeric)as Val from DEFINITION_DETAIL_DATA inner join DEFINITION_MST on DEFINITION_MST.SMID = DEFINITION_DETAIL_DATA.SMID Where DEFINITION_MST.MPID = 176 and Convert(Numeric,Data_Value) > 10000 Value without where condition shows like. 1 2500 2 3500 3 5000 4 10000 5 15000 6 20000 but when i add Convert(Numeric,Data_Value) > 10000 in query then its give me an error. Error converting data type varchar to numeric.

              kiran banker

              M Offline
              M Offline
              Muhammad Shahid Farooq
              wrote on last edited by
              #6

              Your query is absolutely right. But “Data_Value” column contains invalid data, so this error occurs. Invalid data means column contains the following data: -Null -Empty -Special Characters -Spaces Please check the data if contain invalid data then remove & run query, your required result obtained.

              B 1 Reply Last reply
              0
              • M Muhammad Shahid Farooq

                Your query is absolutely right. But “Data_Value” column contains invalid data, so this error occurs. Invalid data means column contains the following data: -Null -Empty -Special Characters -Spaces Please check the data if contain invalid data then remove & run query, your required result obtained.

                B Offline
                B Offline
                banker_kiran
                wrote on last edited by
                #7

                it contains following data. SMID Data_Value 1 2500 2 3500 3 5000 4 10000 5 15000 6 20000

                kiran banker

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups