Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2008
    Posts
    22

    Unanswered: Best way to loop through multiple records

    Hello,
    I have about 20,000 records in my db i want to loop through, process one by one by a function and then log.

    My question is whats the best way to loop through.

    Code:
    declare @loop int, @csv varchar(max)
    
    set @loop = @@rowcount
    while @loop  =1
    begin
    
    
    update top 1000 mytable set updatestatus = 1 where updatestatus = 0
    
    set @csv = select top 1000
    
    Select  @csv = isnull(@csv + ', ', '') + products
    From    myTable
    Where   updatestatus = 1
    
    ---pass @csv to billing function then log
    
    end
    thanks

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Testimonial:
    pootle flump
    ur codings are working excelent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •