Re: update table according to reference table?

From: DWinter (dwinter_at_attbi.com)
Date: 10/03/04


Date: Sat, 2 Oct 2004 23:22:43 -0400

Is the Code, the primary key? Is there an index on the Code? Any triggers
that fire on update?
If Code is the primary key to the table, you may want to remove it and
reapply the constraint after you make the update. You may want to do the
same with any index that is using the Code field, and any trigger that
fires. This is just so you don't do any extra work. But here is your query.

UPDATE OriginalTable SET code=ReferenceTable.new_code FROM ReferenceTable
WHERE ReferenceTable.Current_code=OriginalTable.code

"ttidy" <ttidy@discussions.microsoft.com> wrote in message
news:3D224F65-A116-4AA3-8087-E62E635BE1F9@microsoft.com...
> Hi,
>
> I need to program a update statement to update 4.3 millions records in a
> table, which changes were according to a reference table. What is the
fastest
> way to do this update statment. Thanks so much advance!
>
> Reference table example:
> Current_code new_code
> 1 3
> 2 5
> 3 4
> .. ..
> 999 1220
>
> Needs to update table:
> code address zip
> 1 1st st... 75000
> 2 .. 75001
> 3
> ..
> 999 .. 75009
>
>
>
>



Relevant Pages

  • Re: Timer fires inconsistantely
    ... This like of code "AddHandler t.Elapsed, ... And I have a button that that triggers an event handler: ... commandID = commandID + 1 ... fire fire fire... ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Dylan song for complete beginner?
    ... hands down very easy to play.. ... TWANG ... you that fasten all the triggers.. ... for the others to fire. ...
    (alt.guitar.beginner)
  • Re: Merge Replication Problem
    ... you deselect the check box the triggers will fire. ... Paul Ibison SQL Server MVP, ... (recommended sql server 2000 replication book: ...
    (microsoft.public.sqlserver.replication)
  • Re: Trigger for updated rows when PK changed
    ... >I guess in pure relational theory updating a pk is meaningless - it's always ... Triggers fire based on the user's language, ... changes the primary key gives me a headache. ...
    (microsoft.public.sqlserver.programming)
  • Re: SPID question
    ... Transactional replication does not fire triggers. ... I am not sure if the context would be the same spid, ...
    (microsoft.public.sqlserver.replication)