Postgres and Oracle include generate_series/connect by command to allow incrementing a sequence by more than 1. I have a need to increment a sequence by a variable amount before row insertion. For example in Postgres this would look like the query below:
Postgres和Oracle包含generate_series/connect by命令,以允许将序列增加1以上。在插入行之前,我需要将一个序列增加一个可变数量。例如,在Postgres中,这个查询如下:
select nextval('mytable_seq') from generate_series(1,3);
选择nextval(mytable_seq)从generate_series(1、3);
What would be the recommended way to accomplish this in Microsoft SQL Server?
在Microsoft SQL Server中实现这一点的推荐方法是什么?
1 个解决方案
#1
3
There is a stored procedure call you can use. Alternatively, you could set up some sort of while
loop that calls next value for
multiple times and caches them for use later.
您可以使用一个存储过程调用。或者,您可以设置一些while循环,多次调用next值并缓存它们以供以后使用。
#1
3
There is a stored procedure call you can use. Alternatively, you could set up some sort of while
loop that calls next value for
multiple times and caches them for use later.
您可以使用一个存储过程调用。或者,您可以设置一些while循环,多次调用next值并缓存它们以供以后使用。