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.
  • F Offline
    F Offline
    f amiri882
    wrote on last edited by
    #1

    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?

    P L F 4 Replies 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?

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

      Not enough information. Please provide more details as follows: How many different information is contained in the field? Is the number of different information fixed? Is the sequence of different information fixed? How are they being separated (by comma or single space)?

      F 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?

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

        f,amiri882 wrote:

        the content of this field Containing different of information such as phone number,address and ...

        X|

        f,amiri882 wrote:

        how do I grouping it In various fields?

        You shouldn't; the correct way would be to have a separate field for each of those attributes.

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        F 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?

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

          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 1 Reply Last reply
          0
          • P Peter Leow

            Not enough information. Please provide more details as follows: How many different information is contained in the field? Is the number of different information fixed? Is the sequence of different information fixed? How are they being separated (by comma or single space)?

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

            some record containing 2 or 3 phone number that separate with space or 2dash or 3dash or ... some record containing a sequenece of string or some record containing both of them.

            P 1 Reply Last reply
            0
            • L Lost User

              f,amiri882 wrote:

              the content of this field Containing different of information such as phone number,address and ...

              X|

              f,amiri882 wrote:

              how do I grouping it In various fields?

              You shouldn't; the correct way would be to have a separate field for each of those attributes.

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

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

              what?I don't underestnad :|

              1 Reply Last reply
              0
              • F f amiri882

                some record containing 2 or 3 phone number that separate with space or 2dash or 3dash or ... some record containing a sequenece of string or some record containing both of them.

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

                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.

                OriginalGriffO F 2 Replies Last reply
                0
                • 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.

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

                  Peter, can you do us a favour and not edit spam questions in QA? The instructions from Chris are to not edit the spam messages, just report them as spam and let the community (or a protector) delete them. The reasoning seems to be that from time to time he tries new spam filters and if you edit the message, then they "learn" what is and isn't spam from the edited message, which is no use! Leaving them untouched, but hitting the "spam" button sends the unedited content to the filter, and it shoudl learn to distinguish real spam better. Thanks!

                  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

                  P 1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    Peter, can you do us a favour and not edit spam questions in QA? The instructions from Chris are to not edit the spam messages, just report them as spam and let the community (or a protector) delete them. The reasoning seems to be that from time to time he tries new spam filters and if you edit the message, then they "learn" what is and isn't spam from the edited message, which is no use! Leaving them untouched, but hitting the "spam" button sends the unedited content to the filter, and it shoudl learn to distinguish real spam better. Thanks!

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

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

                    Sorry.

                    OriginalGriffO 1 Reply Last reply
                    0
                    • 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