October 17, 2022 at 6:19 pm
WITH MAXPRedID as (
SELECT MAX(ID) + 1 AS MaxID, SystemID
FROM dbo.TableA
GROUP BY SystemID)
SELECT a.MaxID + COUNT(B.*), b.*
FROM dbo.TableB b
INNER JOIN MaxPredID a
ON b.SystemID = a.SystemID
If my MaxID is 15001 and I have 25 rows in tableB, I need to generate the new 25 IDs for starting at 15001 and ending at 15026.
Using simplistic numbers in this example, could be 2500 rows from tableb, etc
I have looked into a row_number function, doing a union all in an attempt to generate these all with no luck.
A push in the right direction would be greatly appreciated.
October 17, 2022 at 7:21 pm
October 17, 2022 at 7:46 pm
What did you not understand about the following?
https://www.sqlservercentral.com/forums/topic/increment-max-value-by-over-a-complete-dataset
October 17, 2022 at 7:52 pm
This is actually perfect Ken, thank you!
I must have missed the notification for this reply as I am just now seeing it.
Thank again.
October 17, 2022 at 10:05 pm
Use CREATE SEQUENCE See https://www.red-gate.com/simple-talk/databases/sql-server/learn/sql-server-sequence-basics/
Please post DDL and follow ANSI/ISO standards when asking for help.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply