Unique Records for different Thread

  • Hi Everyone,

    I have a requirement to loop through a table and get the unique records and take those records and process further for data manipulation in other tables.

    Structure of the Table:

    Create table logic (order_no int not null, identifier varchar(200) null)

    This table records will be keep on increasing by different application.

    The signature of the stored procedure is :

    Exec Get_records 10

    Logic inside the stored procedure is:

    1. Get the unique_identifier using new_guid function

    2. Set the rowcount as the input of the stored procedure.

        in our example it is 10

    3. Then update the "identifier" column with the new guid id.

    4. select the records where identifier is equal to guid.

    Likewise, if you call this procedure n' number of times I will be able to loop through all the records.

    But, if this procedure is accessed by a multi-threaded application, it leads to a dead-lock.

    Is there a way to loop through the records in a table by a multi-threaded application, which gets a unique records for each of the thread.

    Any help is highly appreciated.

    Thanks,

    Ganesh

     

     

     

  • In the bit that reads the 10 records try using the READPAST query hint.

    This should skip passed the rows being locked by the other thread.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply