Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. COJust to clarify, this seems similar but is different from the suggestion from Thomas, as he suggested trying to insert the data with a ROW_NUMBER() applied first. If there are multiple insert statements happening independently, applying a ROW_NUMBER() first won't work, especially because there may not be an obvious order within the INSERT statement itself.
      singulars
    2. COIf there are multiple inserts happening, the identity approach would also break would it not? You might get gaps or an order that is unexpected (e.g. 1st insert A,B,C which get identity values of 1,2,3. 2nd insert A,B,D which get 4,5,6 but not the same as the sequence). It really comes down to when the OP needs the sequence and I get the impression they need a sequence multiple times thus the question about how to reseed the identity.
      singulars
    3. CO@Thomas, if the op has ensured that the IDENTITY values that get assigned occur in the correct order (I assume he is inserting rows one by one, and that the "order" is dictated by something that is not already in the table) then this approach should work fine. The only problem the op was having is that the values he was getting on subsequent queries from the table were not starting at 1. If he keeps the IDENTITY column he can still pull the data ordered by insert but use ROW_NUMBER() to generate a 1,2,3 sequence regardless of lowest value, gaps, etc.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload