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' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -