sql server - Updating an SQL table from another using certain parameters and only updating certain parameters -



sql server - Updating an SQL table from another using certain parameters and only updating certain parameters -

i working couple of databases using sql server 2008. have noticed 1 of tables in database has wrong info , rectify (as have re-create of table right info in same database) thought utilize update update info 1 table another.

so explanation purposes, table x, has wrong data. table y, has right data.

the wrong info making job more hard unique identifier each record , wanting update these unique identifiers between 2 specific dates.

what have got far is:

update x set x.number = y.number x, y x.date >= '20130107' , x.date <= '20140630' , y.date >= '20130107' , y.date <= '20140630'

unfortunately whilst job, takes unique identifier top row of y , updates rows in x. not looking need y.record1 match x.record1, y.record2 match x.record2 etc.

any help appreciated, , sense free inquire questions should have confused you.

thank you.

you technically create work using

row_number() on (order xyz)

on both filtered sets create temporary keys utilize in update. if augment ctes little easier.

but(!) relatively complex way of solving issue describe. info have given seems lot easier delete bad info , reinsert table still good.

sql sql-server database

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -