Re: Update one database table values with another database table v
- From: kw_uh97 <kwuh97@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 23 Jul 2009 07:29:01 -0700
Thanks Erland worked perfectly. Exactly what I needed. :-)
"Erland Sommarskog" wrote:
kw_uh97 (kwuh97@xxxxxxxxxxxxxxxxxxxxxxxxx) writes:.
Let me preface that I mistakenly updated a hand full of records last
week and would like to undo the updates. I do not have mush
administrative rights so this is the only method that I am aware of the
get back the orignal contents of the records. I would like to update
values of 3 records in a table in one database with the values of 3
records in another database. The structures of the respective database
tables are exactly same so I was wondering if anyone can help me with an
update query to get values of database2.table into database1.table.
UPDATE db1.tbl
SET col1 = b.col1,
col2 = b.col2,
...
FROM db1.tbl a
JOIN db2.tbl b ON a.keycol2 = b.keycol1
AND a.keycol3 = b.keycol2
...
But if you need to ask how to do this, and given your record, I think
you are better off asking someone who knows SQL to do this for you, so
that you don't create an even greater mess. Or as Eric suggested, update
the rows one by one, after having check which values that are different.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
- References:
- Update one database table values with another database table value
- From: kw_uh97
- Re: Update one database table values with another database table value
- From: Erland Sommarskog
- Update one database table values with another database table value
- Prev by Date: Re: query values that do not appear in table
- Next by Date: Re: Problem with SQL Jobs and Linked Server
- Previous by thread: Re: Update one database table values with another database table value
- Next by thread: Help on Date Function
- Index(es):
Relevant Pages
|