Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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 <> ​1 
 + 
 DECLARE @counter INT DECLARE @counter INT
 SET @counter = 1000 SET @counter = 1000
-Set NoCount ​On +  
-WHILE @counter 0+SET NoCount ​ON 
 +  
 +WHILE @counter<​1000000 
 +    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 ​top 100 * from Ledger+SELECT ​top 100 * FROM Ledger
 </​code>​ </​code>​