inserting record into table adds to top of table

  • I am attempting to add a record to a table both via T-SQL or opening the table and adding the record. When I add the record it is inserted at the top of the table (I notice this when I do a refresh on the open table). This table is used for login purposes and also populates who last updated a web form. I don't have access to the web code but it is important that the new data is entered at the bottom of the table. Is there a way I can force this behaviour?

    Thanks in advance.

  • Tables, by definition, have no order.

    If you care about the order of the data, you need to include an ORDER BY clause in any queries you run.

  • Thanks your correct I was able to resolve this issue by creating a new table and updating with the one I am inserting records to and ordering it appropriately.

    Appreciate the response.

  • Tables, by definition, don't have an order. Position of rows within a table is a meaningless concept. The way the rows are stored physically on disk (which is what you affected) has no impact on the order that the rows will be returned. If you do a straight select * from table, you may get the rows back ordered as they are on disk, or you may not.

    If the order is important, put an order by on the queries that select from the table. That's the only time and the only way you can affect order.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

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

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