The most efficient way to import such a text data from a sql server table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cuqsy0
    New Member
    • Apr 2012
    • 22

    The most efficient way to import such a text data from a sql server table

    Greetings,

    Now I have a SQL server table T1 which has one column: Col, and one row. The data looks like this:

    a1,a2,a3,b1,b2, b3,c1,c2,c3,... ,x1,x2,x3

    Now I wish to load it to a new table T2. T2 has three columns: col1, col2,col3, and has many rows. It should look like this:

    Table T2

    --------------
    col1 col2 col3
    --------------
    a1 a2 a3
    b1 b2 b3
    c1 c2 c3

    .............
    x1 x2 x3

    I think of export table T1 to disk, and then bulk insert it in to table T2. But there should be other ways using T-SQL (I am not using SSIS).

    Thanks,

    CUQ
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Use a union all and select it into your new table. I don't know what your data looks like but it sounds unnormalized and you should think about fixing that.
    Last edited by Rabbit; Oct 29 '12, 05:16 AM.

    Comment

    Working...