HOW TO INSERT A RECORD IN ORDER

  • My date table has all 366 dates of year 2008.suppose a date is deleted from the date table ,for instance.

    04-01-2008,I have written a store proceure which adds the deleted dates back to the table,but those records will be added after the existing records that is after 31-12-2008.How do i add the deleted date back in order?

  • The order in which data is stored is not important.

    While SELECTing you have to specify ORDER BY clause and retrieve the data in the required order.

  • Iam aware of the order by clause,wanted to know if there is a way to get those in order while inserting.Many did tell me that its of no importance,still thought it would be nice to know if there is a way to it.Anyways thank you for the reply Suresh.

  • Create a clustered index on the date column. So the data pages are arranged on the order you want. . But there is no guarantee to see the order of the data inserted using select statement. Always to get the order of the way you want, you have to use order clause in your query.

  • A table has no definition of order, it's an unordered set. Hence there's no concept of inserting a row into a particular place.

    Even a clustered index just imposes a logical order to the way the table is stored, it doesn't give the table an order.

    What problem is the insert causing that you want to insert the new row in a specific place?

    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
  • THX guys!! appreicate all the replies...

Viewing 6 posts - 1 through 5 (of 5 total)

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