解决方法
CREATE SEQUENCE dbo.OrderIDs AS INT MINVALUE 1 NO MAXVALUE START WITH 1; SELECT NextOrderID = NEXT VALUE FOR dbo.OrderIDs UNION ALL SELECT NEXT VALUE FOR dbo.OrderIDs UNION ALL SELECT NEXT VALUE FOR dbo.OrderIDs;
结果:
NextOrderID ----------- 1 2 3
有关原始来源和更多示例,请参阅here.该页面引用sql Server Denali,它是sql 2012的beta版,但语法仍然相同.