loop through records and update

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dorandoran
    New Member
    • Feb 2007
    • 145

    loop through records and update

    I have a backend SQL Server table "tblCustome r" and I want to loop through each record and update a field called "pValue".

    1. I am using webservices to read pValue
    2. I need set criteria where wsID = customerID

    Any links or suggestions would be very helpful.

    Thanks
    Last edited by dorandoran; May 28 '08, 05:22 PM. Reason: i missed few things
  • CyberSoftHari
    Recognized Expert Contributor
    • Sep 2007
    • 488

    #2
    You can use cursors in store procedures.

    Comment

    • dorandoran
      New Member
      • Feb 2007
      • 145

      #3
      do you have any example or link for how to build sp with parameter and use it in vb.net?

      Comment

      • CyberSoftHari
        Recognized Expert Contributor
        • Sep 2007
        • 488

        #4
        Code:
        DECLARE Customer CURSOR FOR 
        SELECT    Field1,
                        Field2,
                       Field3
        FROM      CustomerTable
        
        OPEN Customer
        FETCH Customer INTO @Field1,
                            @Field2,
                            @Field3
        -- Your update query here
        WHILE @@Fetch_Status = 0
        
           BEGIN
           -- This is where you perform your detailed row-by-row processing.
        
           -- Get the next row.
           FETCH Customer INTO @Field1,
                               @Field2,
                               @Field3              
        -- Your update query here
           END
        CLOSE Customer
        DEALLOCATE Customer
        you have to modify.

        Comment

        • dorandoran
          New Member
          • Feb 2007
          • 145

          #5
          Thank you very much. i will try it in the morning.

          Comment

          Working...