need help on SQL

  • i've table and data as following,

    declare @t1 table

    (idx int identity, acctInfo int, menuCollection int, tabCollection int);

    /*combination of acctInfo, menuCollection and tabCollection generate a unique row*/

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 1, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 2, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 3, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 4, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 5, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 6, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 7, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 8, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 10, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 11, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 12, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 13, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 14, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 15, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 16, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 17, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 18, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 19, 3)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 20, 4)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 21, 4)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 22, 4)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (1, 23, 4)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 1, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 2, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 3, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 4, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 5, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 6, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (3, 7, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 3, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 13, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 14, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 15, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 16, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 17, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (4, 18, 2)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (5, 2, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (5, 5, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (5, 6, 1)

    INSERT @t1 ([acctInfo], [menuCollection], [tabCollection]) VALUES (5, 19, 1)

    declare @tabCollection int

    set @tabCollection=1

    declare @acctInfo int

    set @acctInfo=4

    declare @menuItem xml

    set @menuItem='<data>

    <menuItem><idx>1</idx></menuItem>

    <menuItem><idx>2</idx></menuItem>

    <menuItem><idx>3</idx></menuItem>

    <menuItem><idx>14</idx></menuItem>

    <menuItem><idx>15</idx></menuItem>

    <menuItem><idx>100</idx></menuItem>

    <menuItem><idx>200</idx></menuItem>

    <menuItem><idx>19</idx></menuItem>

    </data>'

    1. My transaction only on MANIPULATE, which is

    select * from @t1 where acctInfo=@acctInfo and tabCollection=@tabCollection

    2. DO NOT do any transaction to others

    3. if @menuItem not exist in MANIPULATE, please insert the not exist @menuItem into @t1

    4. if MANIPULATE not exist in @menuItem, please delete the not exist MANIPULATE from @t1

    Please help. I'm really stuck

  • It is not clear to me what MANIPULATE means, could you please define.

    Iulian

  • This was removed by the editor as SPAM

  • Stewart is right,

    You can get an overview for XML support from here too.

    Regards,

    Iulian

  • tq to all

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply