all groups > sql server new users > march 2005 >
You're in the

sql server new users

group:

Update at group


Update at group Philip L Holmes
3/31/2005 2:08:22 PM
sql server new users:
Is it possible to update for a group statement, I want to do the following
but keep getting errors :

CREATE PROCEDURE ARCustomerRebalance AS
begin
update cust_detail
set curr_bal = (select(sum(ar_master.bal_amt))
from cust_detail, ar_master
where (cust_detail.cust_code = ar_master.cust_code)
group by cust_detail.cust_code )

end

Thanks in advance

Re: Update at group Adam Machanic
3/31/2005 5:27:29 PM
Try:

CREATE PROCEDURE ARCustomerRebalance
AS
BEGIN
SET NOCOUNT ON

update cust_detail
set curr_bal =
(select sum(ar_master.bal_amt)
from ar_master
where cust_detail.cust_code = ar_master.cust_code)
WHERE EXISTS
(select *
from ar_master
where cust_detail.cust_code = ar_master.cust_code)
END


--
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--


[quoted text, click to view]

Re: Update at group Philip L Holmes
4/4/2005 9:41:08 AM
Works fantastic - thankyou


[quoted text, click to view]

AddThis Social Bookmark Button