Is there a way to do the following:
DECLARE @startVal integer
SELECT
@startIdx = MAX(Range_val)
FROM
[Bookings].[dbo].[Range] (nolock)
INSERT INTO
[Bookings].[dbo].[Range]
VALUES
(INCR(@startVal), 'someVal', 'someOtherVal'),
(INCR(@startVal), 'someVal1', 'someOtherVal3'),
(INCR(@startVal), 'someVal2', 'someOtherVal4'),
Where INCR() is some function that increments the variable. Instead of doing ‘@startIdx + 1’, ‘@startIdx + 2’, etc?
EDIT: This is not necessarily the table index. I know I can drop the table and recreate it the proper way (assuming this is the index), but that’s not my question. Is there a way to increment a variable the way I have described?
If your just looking to make it easier to mess around with & cannot use an
identity column here are a couple of ways to avoid specifying
+1;Or (ids are assigned in an alphabetical not ordinal order based on the 1st
field)
Are you sure you want
nolock?