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. conversion

conversion

Scheduled Pinned Locked Moved Database
tutorialquestion
4 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.
  • P Offline
    P Offline
    pavan kumar p
    wrote on last edited by
    #1

    how to convert a string to integer of length 4?which function to use? P.PaVaN KuMaR

    E 1 Reply Last reply
    0
    • P pavan kumar p

      how to convert a string to integer of length 4?which function to use? P.PaVaN KuMaR

      E Offline
      E Offline
      Eric Dahlvang
      wrote on last edited by
      #2

      select convert(int,ColumnName) from TableName or select cast(ColumnName as int) from TableName ---------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters

      R 1 Reply Last reply
      0
      • E Eric Dahlvang

        select convert(int,ColumnName) from TableName or select cast(ColumnName as int) from TableName ---------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters

        R Offline
        R Offline
        r stropek
        wrote on last edited by
        #3

        I would suggest to add the isnumeric function if you are not absolutely sure that the string ALWAYS contains valid ints:

        select cast( case when isnumeric(ColumnName)=1 then ColumnName else NULL end as int ) from TableName

        Regards, Rainer. Rainer Stropek Visit my blog at http://www.cubido.at/rainers

        E 1 Reply Last reply
        0
        • R r stropek

          I would suggest to add the isnumeric function if you are not absolutely sure that the string ALWAYS contains valid ints:

          select cast( case when isnumeric(ColumnName)=1 then ColumnName else NULL end as int ) from TableName

          Regards, Rainer. Rainer Stropek Visit my blog at http://www.cubido.at/rainers

          E Offline
          E Offline
          Eric Dahlvang
          wrote on last edited by
          #4

          r.stropek wrote:

          select cast( case when isnumeric(ColumnName)=1 then ColumnName else NULL end as int ) from TableName

          Makes sense. Thanks. ---------- Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peters

          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