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
 Update query help

Author  Topic 

reggie
Starting Member

2 Posts

Posted - 2009-06-08 : 19:40:14
Hello,

I am trying to figure out how to do an update query that would perform the following if it is possible but have had no luck as of yet.

table1

item whs date
1234 1 1/5/09
1234 2 null
5678 1 1/7/09
5678 2 null


I would like to update the date field to be the same for every item no matter what the whs column states. Below is what I would like to show after the query.

table1

item whs date
1234 1 1/5/09
1234 2 1/5/09
5678 1 1/7/09
5678 2 1/7/09


Any help would be great!!!

Thanks.

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-08 : 20:01:31
[code]
update t
set date = s.date
from table1 t
inner join table1 s on t.item = s.item
where t.date is null
and s.date is not null
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

reggie
Starting Member

2 Posts

Posted - 2009-06-08 : 21:10:15
You're awesome!

Thanks much!
Go to Top of Page
   

- Advertisement -