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. MS SQL 2000 Server database

MS SQL 2000 Server database

Scheduled Pinned Locked Moved Database
databasesysadmin
16 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.
  • Y Yulianto

    What are you trying to do? I don't understand.


    Work hard, Work effectively.

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

    I have a table with rows and columns. In a column, say A I have cell contents as 12345 etc. That is i have something like: Column Row 12345 Now what I want to do is to separate the numbers in that cell as in 1 23 4 5, so that 1 is in its column, 23 in its column, 4 in its column 5 in its column but all in the same row: Column1 Column2 Column3 Column4 Row 1 23 4 5 If I can be helped in that one cell, I think I will be able to handle the other cells. help needed urgently! phokojoe

    Y 1 Reply Last reply
    0
    • Y Yulianto

      What are you trying to do? I don't understand.


      Work hard, Work effectively.

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

      I have a table with rows and columns. In a column, say A I have cell contents as 12345 etc. That is i have something like: Column Row 12345 Now what I want to do is to separate the numbers in that cell as in 1 23 4 5, so that 1 is in its column, 23 in its column, 4 in its column 5 in its column but all in the same row: Column1 Column2 Column3 Column4 Row 1 23 4 5 If I can be helped in that one cell, I think I will be able to handle the other cells. help needed urgently! phokojoe

      Y 1 Reply Last reply
      0
      • P phokojoe

        I have a table with rows and columns. In a column, say A I have cell contents as 12345 etc. That is i have something like: Column Row 12345 Now what I want to do is to separate the numbers in that cell as in 1 23 4 5, so that 1 is in its column, 23 in its column, 4 in its column 5 in its column but all in the same row: Column1 Column2 Column3 Column4 Row 1 23 4 5 If I can be helped in that one cell, I think I will be able to handle the other cells. help needed urgently! phokojoe

        Y Offline
        Y Offline
        Yulianto
        wrote on last edited by
        #5

        What's the pattern? Why does 1 in its column and 23 in another column?


        Work hard, Work effectively.

        1 Reply Last reply
        0
        • P phokojoe

          I have a table with rows and columns. In a column, say A I have cell contents as 12345 etc. That is i have something like: Column Row 12345 Now what I want to do is to separate the numbers in that cell as in 1 23 4 5, so that 1 is in its column, 23 in its column, 4 in its column 5 in its column but all in the same row: Column1 Column2 Column3 Column4 Row 1 23 4 5 If I can be helped in that one cell, I think I will be able to handle the other cells. help needed urgently! phokojoe

          Y Offline
          Y Offline
          Yulianto
          wrote on last edited by
          #6

          Maybe you can do it in your code. You save the data as 1,23,4,5. Read the data, when "," is found put it into the next column. I can't help much, if you didn't give more information.


          Work hard, Work effectively.

          P 2 Replies Last reply
          0
          • Y Yulianto

            Maybe you can do it in your code. You save the data as 1,23,4,5. Read the data, when "," is found put it into the next column. I can't help much, if you didn't give more information.


            Work hard, Work effectively.

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

            Ok! Thank you for responding. All I can say for example column1 will hold Gender, Column2 will hold Age, column3 will hold say Position" Initially, I have: Column Row 12345 And like I said all I want is a procedure or a way of having it like this: Gender Age Position Class Row 1 23 4 5 I hope this time I have made it clear. Thanks once again!! phokojoe

            Y 1 Reply Last reply
            0
            • P phokojoe

              Ok! Thank you for responding. All I can say for example column1 will hold Gender, Column2 will hold Age, column3 will hold say Position" Initially, I have: Column Row 12345 And like I said all I want is a procedure or a way of having it like this: Gender Age Position Class Row 1 23 4 5 I hope this time I have made it clear. Thanks once again!! phokojoe

              Y Offline
              Y Offline
              Yulianto
              wrote on last edited by
              #8

              For that you can use,

              insert into tableName(gender,age, position, class) values (1,23,4,5)

              Why do you want to separate it, when you can do it easily with the way above?


              Work hard, Work effectively.

              P 1 Reply Last reply
              0
              • Y Yulianto

                For that you can use,

                insert into tableName(gender,age, position, class) values (1,23,4,5)

                Why do you want to separate it, when you can do it easily with the way above?


                Work hard, Work effectively.

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

                It looks like you do not understand. What I am saying is that my dataset is in this form: Column(Data) Row 12345 which is (Gender age position and class concatenated together). that is I have in a cell column a data in that form and all I want to do is to separate the contents of the column(Data) to separate that and have Gender Age Position Class Row 1 23 4 5 I think now it makes more sense. The insert statement I have used it many times and have no problem with that. phokojoe

                Y 1 Reply Last reply
                0
                • P phokojoe

                  It looks like you do not understand. What I am saying is that my dataset is in this form: Column(Data) Row 12345 which is (Gender age position and class concatenated together). that is I have in a cell column a data in that form and all I want to do is to separate the contents of the column(Data) to separate that and have Gender Age Position Class Row 1 23 4 5 I think now it makes more sense. The insert statement I have used it many times and have no problem with that. phokojoe

                  Y Offline
                  Y Offline
                  Yulianto
                  wrote on last edited by
                  #10

                  :confused: Is the problem solved? What I'm saying is you don't need to save the data in 1 column, if you have gender, save it in the gender column, etc. You're just making trouble for your self. I hope, I didn't miss understood you.


                  Work hard, Work effectively.

                  P 1 Reply Last reply
                  0
                  • Y Yulianto

                    :confused: Is the problem solved? What I'm saying is you don't need to save the data in 1 column, if you have gender, save it in the gender column, etc. You're just making trouble for your self. I hope, I didn't miss understood you.


                    Work hard, Work effectively.

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

                    Thanks Yulianto. I will try not to create trouble for myself. The reson why I had that kind of a situation is that, I used a scanner to capture data , so in my questionnaire design, I had group the variables like that so as not to crowd the questionnaire. Thank you phokojoe

                    1 Reply Last reply
                    0
                    • Y Yulianto

                      Maybe you can do it in your code. You save the data as 1,23,4,5. Read the data, when "," is found put it into the next column. I can't help much, if you didn't give more information.


                      Work hard, Work effectively.

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

                      Yulianto Can you show me a line of code whereby if I have data stored in as 1,2,3,4 and I want to read data set, when I find "," I put it in a next clolumn. Sy, when read a data set 1 when i find "," i put 1 in the next column. phokojoe

                      Y 1 Reply Last reply
                      0
                      • P phokojoe

                        Yulianto Can you show me a line of code whereby if I have data stored in as 1,2,3,4 and I want to read data set, when I find "," I put it in a next clolumn. Sy, when read a data set 1 when i find "," i put 1 in the next column. phokojoe

                        Y Offline
                        Y Offline
                        Yulianto
                        wrote on last edited by
                        #13

                        phokojoe wrote: read data set, when I find "," I put it in a next clolumn Are you going to save from the data set? I don't get it. :doh:


                        Work hard, Work effectively.

                        P 1 Reply Last reply
                        0
                        • Y Yulianto

                          phokojoe wrote: read data set, when I find "," I put it in a next clolumn Are you going to save from the data set? I don't get it. :doh:


                          Work hard, Work effectively.

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

                          I will read that data from a table and then save it to another table. I think the code that you are going to show me, I will create a stored procedure and then run it to save it to another table. I think, I have made my point clear. thank phokojoe

                          Y 1 Reply Last reply
                          0
                          • P phokojoe

                            I will read that data from a table and then save it to another table. I think the code that you are going to show me, I will create a stored procedure and then run it to save it to another table. I think, I have made my point clear. thank phokojoe

                            Y Offline
                            Y Offline
                            Yulianto
                            wrote on last edited by
                            #15

                            You're stil making trouble for your self. Anyway, use PATINDEX, to get the string between comma. If your string 'a,b,c' then, the first PATINDEX will get 'a', the second will get 'b', and so on. Then you can update/copy the field using the value you got. Here's the basic code:

                            declare @name varchar(15)
                            set @name='agf,b,c'
                            select substring(@name,1,patindex('%,%',@name)-1)
                            

                            Work hard, Work effectively.

                            P 1 Reply Last reply
                            0
                            • Y Yulianto

                              You're stil making trouble for your self. Anyway, use PATINDEX, to get the string between comma. If your string 'a,b,c' then, the first PATINDEX will get 'a', the second will get 'b', and so on. Then you can update/copy the field using the value you got. Here's the basic code:

                              declare @name varchar(15)
                              set @name='agf,b,c'
                              select substring(@name,1,patindex('%,%',@name)-1)
                              

                              Work hard, Work effectively.

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

                              Thank you. it worked:) phokojoe

                              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