0
I have a table with 12,560 records from 5 years ago, that is, it does not have such a good modeling and it has a field called 'code' that the user filled with something like CA-0001. The problem is that at some point in the history of this database someone skipped a number and I need to know what that number was. What query would I run to find out which line was skipped?
NOTE: I am using SQL Server 2014.
Use an sql of type select * from table t1 Where seq > 1 and not exists (select null from table t2 Where t2.seq = (t1.seq-1))
– Motta
The problem is that the field is in varchar
– Márcio Eric
Use functions like SUBSTRING to get the numeric part and CAST or CONVERT to convert the string to number , CONCAT to recompose the new string
– Motta
Turns into an answer
– Márcio Eric
@Márcioeric: Search by algorithms of gaps and Islands.
– José Diz
No boy, so I can score as solution. It was on record 133
– Márcio Eric
The @Sorack did it.
– Motta