Re: Update one database table values with another database table v

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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


.



Relevant Pages

  • CREATE AGGREGATE failed because type Concatenate does not conform to UDAGG specification due to meth
    ... Now register the assembly and the aggregate in the SQL Server database you want ... I'm trying to do some CLR integration with sql server 2005. ...
    (microsoft.public.sqlserver.programming)
  • Re: How do i move an SQLDatabase to another location?
    ... I went to my clients and installed SQL Server ... Express and copied my database to the same location it was in while i was ... knowing that i can bring a database with me and install ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: New to Windows CE Development - Have some questions
    ... validating against the main database, or querying the database during data ... iterate through the SQL CE table and create new entries in the ... SQL Server database that correspond. ... >>> not connected to the Enterprise. ...
    (microsoft.public.windowsce.app.development)
  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)
  • Re: Using Access 2007 to connect to SQL
    ... MDB database file format, ODBC linked tables, passthrough queries ... probably the easiest way of retrieving data from a SQL-Server ... I'm a total newbie w MS SQL Server. ...
    (microsoft.public.access.adp.sqlserver)