Getting the next ID without inserting a row

前端 未结 5 782
臣服心动
臣服心动 2021-02-05 10:50

Is it possible in SQL (SQL Server) to retrieve the next ID (integer) from an identity column in a table before, and without actually, inserting a row? This is not necessarily th

5条回答
  •  逝去的感伤
    2021-02-05 10:59

    Rather than using an IDENTITY column, you could use a UNIQUEIDENTIFIER (Guid) column as the unique row identifer and insert known values.

    The other option (which I use) is SET IDENTITY_INSERT ON, where the row IDs are managed in a source controlled single 'document'.

提交回复
热议问题