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
 General SQL Server Forums
 New to SQL Server Programming
 Select/Update

Author  Topic 

wallyk
Starting Member

8 Posts

Posted - 2006-06-29 : 18:42:38
Is it possible to update an entire column with data from another table? I have allot of information that is date sensative and would rather just update one column rather than havnig to change the date all the time. I have started this string and am stuck about what tp put after the SET string


UPDATE scf_yfeesycom
SET netrealpl =
SELECT netrealpl
FROM scf_pandl
Where date > 2006-01-31

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2006-06-29 : 18:48:08
You need to do something like:


UPDATE titles
SET ytd_sales = titles.ytd_sales + sales.qty
FROM titles, sales
WHERE titles.title_id = sales.title_id
AND sales.ord_date = (SELECT MAX(sales.ord_date) FROM sales)

This is a Books Online example. Check out the page on UPDATE


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-30 : 02:03:24
Something like

UPDATE T
SET netrealpl =S.netrealpl
FROM scf_yfeesycom T inner join scf_pandl S
on T.keycolumn=S.keycolumn
Where S.date > '2006-01-31'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -