SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2004
    Location
    Sydney, Australia
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unusual Database Entry Sequence

    Hi there

    This may be better in the Database forum but it relates more to .NET so...

    I am using SQL Server 2005 and .NET to run an admin system for our websites. I am used to databases inserting new records at the bottom of the table like:

    1 Data Item 1 Data Item 2
    2 Data Item 1 Data Item 2
    3 Data Item 1 Data Item 2

    My application, when running on localhost, inserted the values as so, with the new records listed at the bottom of the table in sequential order.

    When I moved the application to a remote webhost, it now adds new records to the top of the list, still in sequential order but starting from the top as the attached image indicates.

    While not a problem, I am curious as to why this is.

    Any thoughts?

    David.
    Attached Images Attached Images

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    unless you specify an ORDER BY clause in your SELECT, the database is free to return the rows in whatever order it feels like

    it can store them in whatever order it feels like, too

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Member
    Join Date
    Sep 2007
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you create a clustered index on the table they should return order by that.

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    "should" being the operative word, not "will"

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •