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. separate the content of field

separate the content of field

Scheduled Pinned Locked Moved Database
question
19 Posts 4 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 Peter Leow

    Your table is in a mess, there is no fixed structure at all. The only way out is to do a manual clean up, and before that do remember to backup a copy of the original table. You must at least put in place some structure, say 'name', 'address', 'phone' that is comma separated and in fixed order and fixed number. Only then, you can use my solution to split and insert them into a new table. Work hard.

    F Offline
    F Offline
    f amiri882
    wrote on last edited by
    #10

    can I use length of field?because the length of fields containing a sequence string is very more than phone number,and fields their length is less than phone number is other type information. I think with this way,problem solve but I don't know code.

    P 1 Reply Last reply
    0
    • P Peter Leow

      Sorry.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #11

      No need to apologize - you weren't to know! :laugh:

      Never underestimate the power of stupid things in large numbers --- Serious Sam

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • P Peter Leow

        Assuming your field values is comma separated and is of fixed number, check out this example at sql fiddle. It spilts the multiple-value field and insert them into a new table with separate fields. Adapt it to suit your need.

        F Offline
        F Offline
        f amiri882
        wrote on last edited by
        #12

        thx for your link.

        1 Reply Last reply
        0
        • F f amiri882

          can I use length of field?because the length of fields containing a sequence string is very more than phone number,and fields their length is less than phone number is other type information. I think with this way,problem solve but I don't know code.

          P Offline
          P Offline
          Peter Leow
          wrote on last edited by
          #13

          I suggest you read this to learn how to manipulate string in sql: T-SQL: RIGHT, LEFT, SUBSTRING and CHARINDEX Functions. Good luck.

          F 1 Reply Last reply
          0
          • P Peter Leow

            I suggest you read this to learn how to manipulate string in sql: T-SQL: RIGHT, LEFT, SUBSTRING and CHARINDEX Functions. Good luck.

            F Offline
            F Offline
            f amiri882
            wrote on last edited by
            #14

            Can you help me further?

            P 1 Reply Last reply
            0
            • F f amiri882

              Can you help me further?

              P Offline
              P Offline
              Peter Leow
              wrote on last edited by
              #15

              The real learning comes from doing it yourself. No effort no gain. Have confidence in yourself. If you still encounter problems after trying, then come back to post your problems in the quick answer section.

              F 2 Replies Last reply
              0
              • P Peter Leow

                The real learning comes from doing it yourself. No effort no gain. Have confidence in yourself. If you still encounter problems after trying, then come back to post your problems in the quick answer section.

                F Offline
                F Offline
                f amiri882
                wrote on last edited by
                #16

                I used this link,but I am having trouble.because some records is exception.

                1 Reply Last reply
                0
                • P Peter Leow

                  The real learning comes from doing it yourself. No effort no gain. Have confidence in yourself. If you still encounter problems after trying, then come back to post your problems in the quick answer section.

                  F Offline
                  F Offline
                  f amiri882
                  wrote on last edited by
                  #17

                  can I use SQl-CLR for this problem?

                  1 Reply Last reply
                  0
                  • F f amiri882

                    I have a table that it has a field with nvarchar datataype. the content of this field Containing different of information such as phone number,address and ... how do I grouping it In various fields?

                    F Offline
                    F Offline
                    f amiri882
                    wrote on last edited by
                    #18

                    is there the C# code for this problem?

                    L 1 Reply Last reply
                    0
                    • F f amiri882

                      is there the C# code for this problem?

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #19

                      So, you don't want to understand your own problem and learn how to solve it and then you expect someone else to write code 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