Is there a .NET equivalent to SQL Server's newsequentialid()

前端 未结 10 2183
孤城傲影
孤城傲影 2020-12-02 10:47

We use GUIDs for primary key, which you know is clustered by default.

When inserting a new row into a table it is inserted at a random page in the table (because GUID

10条回答
  •  暖寄归人
    2020-12-02 11:11

    The key problem is knowing what the last value was in a .NET application. SQL Server keeps track of this for you. You will need to hold the last value yourself and use the Guid constructor with a byte array containing the next value. Of course, on a distributed application this probably isn't going to help and you may have to use the randomised Guids. (Not that I see anything wrong with this.)

    http://msdn.microsoft.com/en-us/library/90ck37x3.aspx

提交回复
热议问题