C
C
CityzenUNDEAD2021-08-03 20:38:55
SQL Server
CityzenUNDEAD, 2021-08-03 20:38:55

How to organize automatic recalculation of indexes in the database?

Prompt, whether it is possible to organize such circuit in ms sql.
I am creating a table with 3 fields: int id, int number1, int number2.
Then I create an event, if the number field becomes equal to 100, then the record is deleted from the database.
But in this case, you need to somehow automatically recalculate the id fields of the remaining records.
Is it possible to organize such a scheme and what is the best way to do it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2021-08-03
@tsklab

Rename your table to temporary.
Create a new one with an ID.
Insert your number1 and number2 pairs. The identifier, if you make one, IDENTITY(1,1)will be consistent.
Delete the temporary table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question