Remove record in table A and insert in table B

Discussion in 'C#' started by Aleeya, Sep 20, 2007.

  1. #1
    Is there any way I can remove record from table A and insert the record in table B in the same script.

    Please help me....
     
    Aleeya, Sep 20, 2007 IP
  2. webcosmo

    webcosmo Notable Member

    Messages:
    5,840
    Likes Received:
    153
    Best Answers:
    2
    Trophy Points:
    255
    #2
    Yes you can.
    Steps:
    1. Insert the record on table B from table A
    2. If no error on 1 Remove record from table A
    Done!
     
    webcosmo, Sep 29, 2007 IP
  3. Sellertools

    Sellertools Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Insert into TableA (columnList) Select EquivalentColumnList from TableB WHERE CONDITIONAL
    if @@ROWCOUNT>0
    BEGIN
    Delete from TableB WHERE CONDITIONAL
    END
     
    Sellertools, Oct 14, 2007 IP