Newbie - Moving around (scrambling) data?

Ask a Question related to Microsoft SQL / MS SQL Server, Design and Development.

  1. #1

    Default Re: Newbie - Moving around (scrambling) data?


    "Ricardo Forde" <anonymous@devdex.com> wrote in message
    news:e4Ixd9JRDHA.1712@TK2MSFTNGP12.phx.gbl...
    > Hi I wodnering what is the best way to move data from 1 row to the next.
    > In other words i want to move the firstname from the 50th row to the
    > first and that from the first to the 50th....etc, etc.
    >
    > Any help on this would be great.
    Why are you trying to do this?
    >
    > Thanks a lot.
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Tim Bird Guest

  2. Similar Questions and Discussions

    1. moving data from one data source to another
      I'm trying to move data from one data source to another. I don't want to loop - because it will kill performance. A simple Select into or Insert...
    2. Newbie needs help with moving backgrounds
      I am a newbie trying to figure out how to do a front-to-back moving background for a game. I want to have my character remain in the center of the...
    3. Netscape inside firewall scrambling Flash
      Help- I've taken over a site created by students. The administration wants me to fix it but content on many pages isn't even visible on computers...
    4. moving data with imbedded <CR> or <LF>
      I have run into an interesting problem. We have generated data that contains bit data stored in a 16 byte character field. This last week I was...
    5. Newbie : Moving data from datagrid to datagrid
      Hello, I have a dataset1, inside a table1 and a dataview1. I have a datagrid1 with datasource the dataview1. I have another datagrid2. I want,...
  3. #2

    Default Re: Newbie - Moving around (scrambling) data?

    I would add another column to the table : ALTER TABLE <YourTableName> ADD
    MyRowID INT IDENTITY
    Looks like you need a temporary row to aid in swapping so add a row and make
    note of its MyRowID value , call this <TempRowID>
    Then to swap 50th and 1st :

    UPDATE <YourTableName> SET FirstName = ( SELECT FirstName FROM
    <YourTableName> WHERE MyRowID = 1) WHERE MyRowID = <TempRowID>
    UPDATE <YourTableName> SET FirstName = ( SELECT FirstName FROM
    <YourTableName> WHERE MyRowID = 50 ) WHERE MyRowID = 1
    UPDATE <YourTableName> SET FirstName = ( SELECT FirstName FROM
    <YourTableName> WHERE MyRowID = <TempRowID> ) WHERE MyRowID = 50

    When finished delete the temp row


    - Chris Brooksbank

    "Ricardo Forde" <anonymous@devdex.com> wrote in message
    news:e4Ixd9JRDHA.1712@TK2MSFTNGP12.phx.gbl...
    > Hi I wodnering what is the best way to move data from 1 row to the next.
    > In other words i want to move the firstname from the 50th row to the
    > first and that from the first to the 50th....etc, etc.
    >
    > Any help on this would be great.
    >
    > Thanks a lot.
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    Chris Brooksbank Guest

  4. #3

    Default Re: Newbie - Moving around (scrambling) data?

    Aaron has some paging info here... [url]http://www.aspfaq.com/show.asp?id=2120[/url]

    --
    -oj
    RAC v2.2 & QALite!
    [url]http://www.rac4sql.net[/url]


    "Ricardo Forde" <anonymous@devdex.com> wrote in message
    news:e4Ixd9JRDHA.1712@TK2MSFTNGP12.phx.gbl...
    > Hi I wodnering what is the best way to move data from 1 row to the next.
    > In other words i want to move the firstname from the 50th row to the
    > first and that from the first to the 50th....etc, etc.
    >
    > Any help on this would be great.
    >
    > Thanks a lot.
    >
    >
    >
    > *** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
    > Don't just participate in USENET...get rewarded for it!

    oj Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139