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

Search text in stored procedure in SQL Server

SELECT *   FROM   sys.procedures WHERE  Object_definition(object_id) LIKE '%keyword%'