Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Inserting at a specific row

Inserting at a specific row

Scheduled Pinned Locked Moved Database
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Esmo2000
    wrote on last edited by
    #1

    Is it possible to insert data at a specific row? Ie. put a row of data right at the top of a table? Thanks a lot, Jim Did I post well? Rate it! Did I post badly? Rate that too!

    C 1 Reply Last reply
    0
    • E Esmo2000

      Is it possible to insert data at a specific row? Ie. put a row of data right at the top of a table? Thanks a lot, Jim Did I post well? Rate it! Did I post badly? Rate that too!

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Databases are set based systems, therefore there is no concept of the "top of [the] table". However, clustered indexes mean that even although there is no logical concept there is a physical structure in place which will put a row at the top of the table. So, perhaps what you needing to do is to create a clustered index on the column that you want to determine the sequence of the rows. However, you need to be careful as this will be the order that the rows are physically stored. Clustered indexes do not work so well if the column values are not unique as any searches will have to resort to a sequential search if there are duplicate values. Alternatively, if all you need is a specific order, for example display purposes, then what you need to do is to create a new column to store some sort of virtual row number, you can then assign a number to it indicating the row's position in the table. When you need to have the rows being returned in a certain sequence you can use the ORDER BY clause on the SELECT statement to return the rows in the order you need. Does this help?


      My: Blog | Photos | Next SQL Presentation WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups