我们可以在 Azure SQL 池中创建一个包含自动增量列的 table 吗?

Can we create a table in Azure SQL pool that contain a autoincrement column?

我想创建一个 table,它应该包含一个从 1 开始到 1 递增的 Id 列,如 1,2,3,4....n 有一个功能标识,但在突触池,它不适用于顺序自动增量。 Azure SQL Pool

中是否还有其他功能可用

解决方案 1:
如果我们想要一个顺序值,那么在 SELECTing 数据时使用 ROW_NUMBER()OVER(partition by <Grouping_field> ,order by <Sort_field> ) 之类的东西。


解决方案 2:

正如这个 post 所说,我们可以使用 table 来存储 Identity 列值。每次插入数据前取max(id)列递增。

 DECLARE @MaxRowId int
 SET @MaxRowId = (SELECT ISNULL(MAX(id),0)+1 FROM dbo.test)