SQL Swapping column data

  • SQL DB

    I want to swap data around from one column to another.

    I have a table called 'PandL' and Im looking at the following data:

    SELECT *

    FROM PandL

    WHERE Currency not like 'GBP'

    AND Currency not like 'ZAR'

    AND Date >= '04/08/08'

    order by date desc

    I want to swap the data from column 'Local' to 'Foreign' and vis versa.

    Whats the easiest way to do this?

    Thanks

  • pri.amin (9/23/2008)


    SQL DB

    I want to swap data around from one column to another.

    I have a table called 'PandL' and Im looking at the following data:

    SELECT *

    FROM PandL

    WHERE Currency not like 'GBP'

    AND Currency not like 'ZAR'

    AND Date >= '04/08/08'

    order by date desc

    I want to swap the data from column 'Local' to 'Foreign' and vis versa.

    Whats the easiest way to do this?

    Thanks

    update PandL

    set Local =Foreign ,Foreign =Local

    WHERE Currency not like 'GBP'

    AND Currency not like 'ZAR'

    AND Date >= '04/08/08'


    Madhivanan

    Failing to plan is Planning to fail

  • Thanks very much, worked well!! 🙂

  • pri.amin (9/23/2008)


    Thanks very much, worked well!! 🙂

    You are welcome 🙂


    Madhivanan

    Failing to plan is Planning to fail

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

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