Results 1 to 3 of 3

Thread: data transpose

  1. #1
    Join Date
    Oct 2008
    Posts
    4

    Unanswered: data transpose

    Hi all,

    I have a table1 & table2 as below, I want to transpose data from table1 to table two as below, could you plz help me in writing a stored proc to carry out this.

    table1

    --------------------------------------------------------------------------------






    unique_id tab_nm field1 field2 field3 fvalue1 fvalue2 fvalue3
    ---------------------------------------------------------------------
    1 tab1 eno ename seq 121 aak 1
    2 tab1 eno ename 122 shb
    3 tab1 acode INTO
    4 tab2 eno ename seq 123 sob 1

    like wise many records






    [/hr]




    --------------------------------------------------------------------------------





    Table 2

    ch_id rec_id rec_no field_nm new_val eno tab_name
    ----------------------------------------------
    1 1 1 eno 121 121 tab1
    2 1 2 ename aak 121 tab1
    3 1 3 seq 1 121 tab1

    4 2 1 eno 122 122 tab1
    5 2 2 ename shb 122 tab1

    6 3 1 acode INTO tab1


    7 1 1 eno 123 123 tab2
    8 1 2 ename sob 123 tab2
    9 1 3 seq 1 123 tab2
    Last edited by aakcse; 03-23-09 at 16:45.

  2. #2
    Join Date
    Oct 2008
    Posts
    4
    Here it is given in more detail..

    SQL Server Forums - transpose of data

  3. #3
    Join Date
    Oct 2008
    Posts
    4

    help with string

    Hi all,

    I want to use the string function inthe where clause to check

    say for eg.

    I have col values as krahul,akumar,spavan_dk,ssujat_py
    I want to equate this values to

    'krahul' eliminate k and equate to 'rahul'
    'akumar' eliminate a and equate to 'kumar'
    'spavan_dk' eliminate s and _dk and equate to 'pavan'
    'ssujat_py' elimniate s and _py and equate to 'sujat'


    take it as col A tab1 contains krahul,akumar,spavan_dk,ssujat_py

    and col B of tab2 rahul,kumar,pavan,sujat

    I am trying with char index and patindex plz help.

    regards,
    aak

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •