Differences
This shows you the differences between two versions of the page.
|
control_sql_-_resequence_the_gl_table [2019/01/27 11:29] 127.0.0.1 external edit |
control_sql_-_resequence_the_gl_table [2019/02/05 11:33] (current) admin |
||
|---|---|---|---|
| Line 39: | Line 39: | ||
| <code sql> | <code sql> | ||
| - | -- Update Ledger Set NewID = 1 where NEWID 1 | + | -- Update Ledger Set NewID = 1 where NEWID <> |
| + | |||
| DECLARE @counter INT | DECLARE @counter INT | ||
| SET @counter = 1000 | SET @counter = 1000 | ||
| - | Set NoCount | + | |
| - | WHILE @counter 0 | + | SET NoCount |
| + | |||
| + | WHILE @counter< | ||
| + | BEGIN | ||
| + | UPDATE TOP (1) L | ||
| + | SET NewID = @counter | ||
| + | FROM Ledger L | ||
| + | WHERE NEWID = 1 | ||
| + | ; | ||
| + | SET @counter = @counter + 1 | ||
| + | END | ||
| + | |||
| + | SET NoCount Off | ||
| + | ; | ||
| + | UPDATE Ledger | ||
| + | SET ID = NewID | ||
| + | WHERE ID > 0 | ||
| ; | ; | ||
| - | select | + | SELECT |
| </ | </ | ||