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. remove commas in a column in mssql

remove commas in a column in mssql

Scheduled Pinned Locked Moved Database
databasesql-serverhelp
8 Posts 2 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
    phokojoe
    wrote on last edited by
    #1

    i have a string data in a column in an msqsql database table and the values are separated by commas (,)eg 01,02,M,1,045,12,1948 i want to remove the commas in that column so that the data looks like 0102M1045148. can any one help me . thanks members :sigh:

    phokojoe

    B 1 Reply Last reply
    0
    • P phokojoe

      i have a string data in a column in an msqsql database table and the values are separated by commas (,)eg 01,02,M,1,045,12,1948 i want to remove the commas in that column so that the data looks like 0102M1045148. can any one help me . thanks members :sigh:

      phokojoe

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      select replace(Columnname,',','') from TableName


      I Love T-SQL "Don't torture yourself,let the life to do it for you."

      P 1 Reply Last reply
      0
      • B Blue_Boy

        select replace(Columnname,',','') from TableName


        I Love T-SQL "Don't torture yourself,let the life to do it for you."

        P Offline
        P Offline
        phokojoe
        wrote on last edited by
        #3

        thanks Blue_Boy, i am going to try it, but by the look of the syntax, it will work. thanks once more :-D

        phokojoe

        B 1 Reply Last reply
        0
        • P phokojoe

          thanks Blue_Boy, i am going to try it, but by the look of the syntax, it will work. thanks once more :-D

          phokojoe

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          I have tested that query and it has worked for me, and sure will work for you too.


          I Love T-SQL "Don't torture yourself,let the life to do it for you."

          P 1 Reply Last reply
          0
          • B Blue_Boy

            I have tested that query and it has worked for me, and sure will work for you too.


            I Love T-SQL "Don't torture yourself,let the life to do it for you."

            P Offline
            P Offline
            phokojoe
            wrote on last edited by
            #5

            i have just tested it, but the problem is, i have so many entries in that column. when i write a column name, it does not replace the commas, instead it returns the column name not even the entries in that column. eg. like i said, the values in that column are of this shape: 01,02,M,045,1948,2,21 and the column name (field) is say column1 i will write: select replace('column1',',','') it only returns column1 not 0102M0451948221. please help me on this. :rolleyes:

            phokojoe

            B 1 Reply Last reply
            0
            • P phokojoe

              i have just tested it, but the problem is, i have so many entries in that column. when i write a column name, it does not replace the commas, instead it returns the column name not even the entries in that column. eg. like i said, the values in that column are of this shape: 01,02,M,045,1948,2,21 and the column name (field) is say column1 i will write: select replace('column1',',','') it only returns column1 not 0102M0451948221. please help me on this. :rolleyes:

              phokojoe

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              phokojoe wrote:

              select replace('column1',',','')

              is not correct bcause you have write columnename inside single qutes Try again code down below Select replace(columname,',','') from tablename


              I Love T-SQL "Don't torture yourself,let the life to do it for you."

              P 1 Reply Last reply
              0
              • B Blue_Boy

                phokojoe wrote:

                select replace('column1',',','')

                is not correct bcause you have write columnename inside single qutes Try again code down below Select replace(columname,',','') from tablename


                I Love T-SQL "Don't torture yourself,let the life to do it for you."

                P Offline
                P Offline
                phokojoe
                wrote on last edited by
                #7

                yah yah yah, without you i could have not survived this stress. i have done it! it works. thanks once more.

                phokojoe

                B 1 Reply Last reply
                0
                • P phokojoe

                  yah yah yah, without you i could have not survived this stress. i have done it! it works. thanks once more.

                  phokojoe

                  B Offline
                  B Offline
                  Blue_Boy
                  wrote on last edited by
                  #8

                  You are welcome.


                  I Love T-SQL "Don't torture yourself,let the life to do it for you."

                  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