sql server - How to insert an item in a database and sort again -


suppose have database primarykey id , varchar name, , need data ordered id.

so data is

  1. james
  2. jhon
  3. patrick

and on

and want insert row in second row

  1. james
  2. lee
  3. john
  4. patrick

how can it?

do have update rows after "lee" , change id?

is there simpler way keep order?

thank you. learn here lot

why want "insert row in second row"? doing indeed require update other records, , should not changing primary key values of records. changing them require updates in tables have foreign keys referring table.

let database handle primary keys. if need number sort of priority or sorting purposes, suggest separate column that.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -