Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8395999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:26:00+00:00 2026-06-09T20:26:00+00:00

I have a SQL Server table that is using a uniqueidentifier as a clustered

  • 0

I have a SQL Server table that is using a uniqueidentifier as a clustered primary key. After creating the table and inserting several rows, I rebooted my server. The column uses NEWSEQUENTIALID() as its default value.

After reboot however, the next insert created a row with a GUID that was lower in value than those before, causing it to appear at the top of a SELECT * statement.

My question: is there any way to prevent shuffling (AKA preserve the ordering of rows) while using a GUID type clustered primary key?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:26:02+00:00Added an answer on June 9, 2026 at 8:26 pm

    If you want to guarantee chronological order, add a column called CreatedDate, set it to not allow NULLs, and set the default to CURRENT_TIMESTAMP. Then to get the last 10 rows, you can say:

    SELECT TOP 10 (*) FROM dbo.foo ORDER BY CreatedDate DESC;
    

    This way your TOP makes sense. Without ORDER BY, as marc explained, your TOP is meaningless and while the results will be relatively predictable (they’re not quite random, I’d prefer the term “arbitrary”), they are not going to have any reliability to be ordered in the same order they were inserted. This is true whether you use a GUID or an integer for your primary key – no guarantees.

    You are never going to be able to guarantee order preservation with NEWSEQUENTIALID(), sorry, that’s just not how it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 database table that uses uniqueidentifier as a primary
I'm using SQL Server 2008 and I have a table that has a 'Status'
I have a SQL Server table in production that has millions of rows, and
I'm using SQL Server 2008. I have a database table that looks like this
I have a database table that uses Sql Server 2005's uniqueidentifier column. I know
I have a sql server table with 2 fields, ID (primary key) and Name
I'm using SQL Server 2k8 and have a table that needs to be able
Using SQL Server 2000. I have a table that receives a dump from a
I have a SQL Server table that contains some datetime data. I'm using a
I have an SQL Server 2005 table that has a varchar(250) field which contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.