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 with a select

Author  Topic 

Rheinhardt
Yak Posting Veteran

66 Posts

Posted - 2009-07-28 : 01:58:04
Hi,

I want to update a table (customer_master) column...basically I want to set the [stop code] column= the same [stop code] column in the table cust_stopcodes where the fields are blank in [stop code](customer_master)

see below:

select c.*,s.[stop code] from customer_master c
join cust_stopcodes s
on c.[customer no]=s.[customer no]
where c.[stop code]='' or c.[stop code]=' ' or c.[stop code]is null

update customer_master c
set c.[customer no]=s.[customer no] where c.[stop code]='' or c.[stop code]=' ' or c.[stop code]is null

Please assist?

Thanks

Rheinhardt
Yak Posting Veteran

66 Posts

Posted - 2009-07-28 : 02:02:46
Thanks!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-28 : 02:03:10
[code]
update customer_master c
set c.[customer no]=s.[customer no] c.[stop code] = s.[stop code]
from customer_master c inner join cust_stopcodes s on c.[customer no] = s.[customer no]
where c.[stop code]='' or c.[stop code]=' ' or c.[stop code]is null

[/code]


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

Go to Top of Page
   

- Advertisement -