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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -