Append Update?

Hi All,

Is it possible to 'add' to an existing value within an update statement?

Basically I have the stored procedure below:

SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


ALTER   proc dbo.ash_add_holiday_request(
@start DATETIME,
@end DATETIME,
@hrs FLOAT,
@staff_id INT
)
AS
SET NOCOUNT ON
BEGIN

INSERT INTO dbo.ash_holiday_requests
VALUES(@staff_id, @start, @end,@hrs,0,NULL,0,0)

SELECT IDENT_CURRENT('dbo.ash_holiday_requests')

DECLARE @old_planned_hours =
                  (SELECT hol_planned
                   FROM dbo.ash_holiday
                   WHERE staff_id = @staff_id)

UPDATE dbo.ash_holiday
SET hol_planned = @hrs + @old_planned_hours
WHERE staff_id = @staff_id

END

GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO


As you can see, I'm retrieving an existing value of planned_hols so that I can 'add' to it. Is there an easier way of doing this?

Thanks

Jell


LVL 12
James ElliottManaging DirectorAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jinesh KamdarCommented:
UPDATE dbo.ash_holiday
SET hol_planned = @hrs + hol_planned
WHERE staff_id = @staff_id
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
James ElliottManaging DirectorAuthor Commented:
lol, knew it would be simple.

Ty

Jell

0
Jinesh KamdarCommented:
Glad to be of help :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.