Questions tagged [newsequentialid]
32 questions
9
votes
4 answers
GUID COMB strategy in EF
Is there any way to implement the Guid COMB identity strategy for objects in the new Entity Framework 4.1 using the CodeFirst design? I thought setting the StoreGeneratedPattern would work, but it still gives me normal GUIDs.

Ciel
- 17,312
- 21
- 104
- 199
9
votes
3 answers
How to sort sequential GUIDs in C#?
Sequential GUIDs are unique but are created with an order; that order is slightly unusual and is different to the order achieved when using the standard .NET Guid comparer.
I'm looking for a C# Guid comparer that will sort by the rules of sequential…

redcalx
- 8,177
- 4
- 56
- 105
7
votes
4 answers
How predictable is NEWSEQUENTIALID?
According to Microsoft's documentation on NEWSEQUENTIALID, the output of NEWSEQUENTIALID is predictable. But how predictable is predictable? Say I have a GUID that was generated by NEWSEQUENTIALID, how hard would it be to:
Calculate the next value?…

Martin Devillers
- 17,293
- 5
- 46
- 88
7
votes
1 answer
Entity Framework 5 code first newsequentialid() as PK
How can I use newsequentialid() as default value in the PK column?
I have this annotation:
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
But this will generate random guid's I would like to have sequential guid's.
I can set by hand the…

Roger Far
- 2,178
- 3
- 36
- 67
6
votes
1 answer
NewSequentialId on UniqueIdentifier Clustered Index
I am working on database standards for a new database my company is starting. One of the things we are trying to define is Primary Key and Clustered Index rules in relation to UniqueIdentifiers.
(NOTE: I do not want a discussion on the pros and…

Vaccano
- 78,325
- 149
- 468
- 850
6
votes
1 answer
Why does using NEWID() use more space than NEWSEQUENTIALID()?
I'm in the middle of doing a bit of research, and I've come across an anomaly that I can't explain (and I've not been able to find anything on Google). Consider the following SQL:
CREATE TABLE MyGuid (
ID UNIQUEIDENTIFIER PRIMARY KEY DEFAULT…

Spikeh
- 3,540
- 4
- 24
- 49
5
votes
4 answers
Changing newid() to newsequentialid() on an existing table
At the moment we have a number of tables that are using newid() on the primary key. This is causing large amounts of fragmentation. So I would like to change the column to use newsequentialid() instead.
I imagine that the existing data will remain…

cbp
- 25,252
- 29
- 125
- 205
5
votes
3 answers
Is there an R function to sequentially assign a code to each value in a dataframe, in the order it appears within the dataset?
I have a table with a long list of aliased values like this:
> head(transmission9, 50)
# A tibble: 50 x 2
In_Node End_Node
1 c4ca4238 2838023a
2 c4ca4238 d82c8d16
3 c4ca4238 a684ecee
4 c4ca4238 fc490ca4
5 28dd2c79…

gbg
- 69
- 5
4
votes
2 answers
Generated Sequential GUIDs are sometimes not sequential
I have a C# application that generates a Sequential GUID for each row that I insert into a table. I expect the inserted GUIDs to be sequential, but sometimes they break sequence (in chunks).
Example:
These GUIDs are shown in the order that they…

Kyle Williamson
- 2,251
- 6
- 43
- 75
4
votes
1 answer
using NEWSEQUENTIALID() with UPDATE Trigger
I am adding a new GUID/Uniqueidentifier column to my table.
ALTER TABLE table_name
ADD VersionNumber UNIQUEIDENTIFIER UNIQUE NOT NULL DEFAULT NEWSEQUENTIALID()
GO
And when ever a record is updated in the table, I would want to update this column…

ram
- 11,468
- 16
- 63
- 89
3
votes
0 answers
NEWSEQUENTIALID() is broken in SQL Server for linux?
I am running MS SQL Server for linux from a Docker image (https://hub.docker.com/r/microsoft/mssql-server-linux/)
I've discovered in my log files, that there are many PRIMARY KEY violations on my log table, which has ID uniqueidentifier DEFAULT…

wojciech_rak
- 2,276
- 2
- 21
- 30
3
votes
2 answers
newid() with Entity Framework 6 Code First
I want to set the default value of my primary key of a table in SQL database with newid() via Entity Framework 6 Code First.
I know how this is done via code and also found some approaches on stackoverflow, like How to set NewId() for GUID in entity…

Oliver Müller
- 545
- 1
- 5
- 17
3
votes
2 answers
Should a Sequential Guid primary key column be a clustered index?
The goal of using a sequential guid is so you can use clustered indexes without the high levels of fragmentation that would normally exist in a clustered index if it was a regular guid, correct?

Chris Marisic
- 32,487
- 24
- 164
- 258
2
votes
1 answer
How to get inserted NewSequentialId value when doing multiple inserts?
Does SQL Server guarantee that NewSequentialId() will be called for each row in the order specified by the ORDER BY clause of an INSERT statement?
The goal is to take a list of objects in C#, each of which represents a row to be inserted in a table,…

Vinny
- 108
- 7
2
votes
2 answers
Creating unique groups in sequential data that repeats through time
This kind of thing has been asked before, but not quite in this way that I can find.
Thread about creating sequential IDs, with several additional links
It's not hard to create identifiers in a sequence, but my data includes a temporal element that…

JHegg
- 61
- 1
- 10