SQL Server insert loop of strings -


thank in advance here.

i want insert incremental numbers strings load bulk test numbers db, here i'm using:

declare       @serialcounter bigint   set @serialcounter = 0   while @serialcounter < 10      insert [tracktrace].[dbo].[tab_element] ([serial], [batch], [batch_id], [qcsample], [stationid])      values(convert(varchar(60), @serialcounter), 'test', 8989, 0, 1)       set @serialcounter = (@serialcounter + 1) 

but when not increment counter , insert duplicate numbers , not stop. think problem variable incremented outside of while loop, not sure how rectify this.

declare  @serialcounter bigint  set @serialcounter = 0  while @serialcounter < 10  begin   print @serialcounter     --insert [tracktrace].[dbo].[tab_element]      --([serial]      --,[batch]      --,[batch_id]      --,[qcsample]      --,[stationid])      --values(convert(varchar(60),@serialcounter),'test',8989,0,1)      set @serialcounter = (@serialcounter +1 ) end 

you not giving begin , end loops first statement considered


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -