Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update query

Author  Topic 

VinnyPip
Starting Member

7 Posts

Posted - 2009-07-22 : 17:03:10
I have to update:

Table A Column 1 with Table 2 Column 2
where Table 1 Column 1 = Table 2 Column 1

help please!

VinnyPip
Starting Member

7 Posts

Posted - 2009-07-22 : 17:04:54
sorry...

Table 1 Column 1 with Table 2 Column 2
where Table 1 Column 1 = Table 2 Column 1
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-22 : 17:25:03
UPDATE t1
SET t1.col1 = t2.col2
FROM Table1 AS t1
INNER JOIN Table2 AS t2 ON t2.col1 = t1.col1


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

VinnyPip
Starting Member

7 Posts

Posted - 2009-07-22 : 17:48:15
how about this one? look right?

UPDATE Table1
SET Column1 = minitable.Column2
FROM
(SELECT Column1,Column2
FROM Table2) as minitable
WHERE Table1.Column1 = minitable.Column1
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-22 : 17:50:06
What happened when you tried?



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

VinnyPip
Starting Member

7 Posts

Posted - 2009-07-22 : 18:23:58
to be honest i think mine did work... but verifying through hundreds of transaction is something that will have to wait till the AM

thanks Peso... you're the man!
Go to Top of Page
   

- Advertisement -