I am using SQL Server 2012 (v11.0.2100) and I want to create a sequence that starts with a random (dynamic) number but I wasn't able to do this, also I put my effort to find a good solution for this but I haven't found something that will satisfy me.
The case that I tried and failed:
DECLARE @sth bigint
SET @sth = 1000
ALTER SEQUENCE StreamEntrySequence
RESTART WITH @sth;
Error :
Incorrect syntax near '@sth'
An ugly solution
declare @sth bigint;
declare @i bigint;
SET @sth = 100000 ;
while @i<@sth;
BEGIN
SET @i= next value for StreamEntrySequence;
END
Is there other way to set the current value or the start value to a random value? Maybe using server procedures?
StreamEntryID