Friday, 9 December 2016

How to Use While LOOP in SQL

  1. DECLARE @TOTALV BIGINT  
  2. DECLARE @InitialValue BIGINT  
  3. SET @InitialValue=1  
  4. SET @TOTALV=12  
  5. WHILE (@InitialValue<=@TOTALV)  
  6. BEGIN  
  7. print @InitialValue  
  8. SET @InitialValue=@InitialValue+1  
  9. END  

No comments:

Post a Comment

Resetting IDENTITY Seed in Table Variable

For a "normal" table, you would use:  DBCC  CHECKIDENT( ' [table_name]' , RESEED, [new_reseed_value]). you cannot reseed...