Professional Web Applications Themes

Newbie - Moving around (scrambling) data? - Microsoft SQL / MS SQL Server

"Ricardo Forde" <anonymousdevdex.com> wrote in message news:e4Ixd9JRDHA.1712TK2MSFTNGP12.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!...

  1. #1

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


    "Ricardo Forde" <anonymousdevdex.com> wrote in message
    news:e4Ixd9JRDHA.1712TK2MSFTNGP12.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. #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" <anonymousdevdex.com> wrote in message
    news:e4Ixd9JRDHA.1712TK2MSFTNGP12.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

  3. #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" <anonymousdevdex.com> wrote in message
    news:e4Ixd9JRDHA.1712TK2MSFTNGP12.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

Similar Threads

  1. moving data from one data source to another
    By adumas77 in forum Coldfusion - Advanced Techniques
    Replies: 2
    Last Post: April 7th, 10:57 PM
  2. Newbie needs help with moving backgrounds
    By footballhead@gmail.com in forum Macromedia Flash
    Replies: 0
    Last Post: March 18th, 05:18 PM
  3. Netscape inside firewall scrambling Flash
    By jbabe webforumsuser@macromedia.com in forum Macromedia Flash Sitedesign
    Replies: 0
    Last Post: December 16th, 05:18 PM
  4. moving data with imbedded <CR> or <LF>
    By Jack in forum IBM DB2
    Replies: 3
    Last Post: September 22nd, 01:57 AM
  5. Newbie : Moving data from datagrid to datagrid
    By C. KIlitzirakis in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: September 3rd, 08:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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