Jes Sie

Jes Sie

  • 742
  • 1.2k
  • 281k

Generating a Sequential Number from SQL SERVER

Mar 25 2017 11:09 AM
I'm making a sequence number form Certificate of Insurance booklet given to the agents so that the CI numbers can be tracked. My code is attached below:
  1. CREATE PROCEDURE [dbo].[CI_SEQUENTIAL_Number]  
  2.     (  
  3.         @StartingNumber int,  
  4.         @EndingNumber int,  
  5.         @Header int  
  6.     )  
  7. AS  
  8.   
  9. DECLARE @start int  
  10. DECLARE @end int  
  11.   
  12. SELECT @start = @StartingNumber, @end = @EndingNumber  
  13.   
  14.     WHILE @start <= @end  
  15.         begin  
  16.   
  17.         INSERT INTO dbo.tblSeriesDetails  
  18.   
  19.                 (SeriesNumbers)  
  20.   
  21.         VALUES(@start)  
  22.   
  23.         SET @start = @start + 1  
  24.       
  25.         where SeriesHeader_Id = @Header  error in this area.
  26.   
  27.     END  
 without the where clause, it is running but when I insert the where clause i got an error "
Msg 156, Level 15, State 1, Procedure SEQUENTIAL, Line 25
Incorrect syntax near the keyword 'where'." Still newbie and still acquiring knowledge in sql server. Thanks for any help.

Answers (4)