Loading ...
Sorry, an error occurred while loading the content.

what is the best update statement

Expand Messages
  • SARADADEVI
    Hi Team,   here are two table: LookUp and Users   Lookup table has: From_ID, To_ID, and FName   User Table has: ID, and FName   Compisite key  on From_ID,
    Message 1 of 1 , Apr 16, 2011
    • 0 Attachment
      Hi Team,
       
      here are two table: LookUp and Users
       
      Lookup table has: From_ID, To_ID, and FName
       
      User Table has: ID, and FName
       
      Compisite key  on From_ID, To_ID and Primary key on ID
       
      There are no overlaps in the Lookup table, but the table does not cover all possible IDs.
       
      If we find a user with an ID # that is not covered by Lookup we should set the FName  to NULL
       
      We have a table of users and we want to fill in the country for each user using the lookup table.
       
      there are 100000 records
       
      what is the best update statement
       
      UPDATE dbo.Users
      SET FName = (
          SELECT FName
          FROM dbo.Lookup
          WHERE ID >= from_iD and iD <= to_ID
      )
       
      this is my update statement but it takes long time
       
      how can i do this?
       
      can we tweak the query
      Thanks & regards,
      Kishore


       

      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.