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
 Adding money values

Author  Topic 

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2009-01-08 : 09:04:27
CREATE PROCEDURE sp_update_booking_prices
(
@booking_id int,
@supp_price money
)
AS
declare @bookingcost money,
@totalcost money



set @bookingcost = (SELECT booking_cost_no_extras from tb_owner_email Where email_id = @booking_id)
Print(@bookingcost)

set @totalcost = @bookingcost + @supp_price


I got this far with writing a stored procedure. At the point of adding 2 money values together, SQL states Error 257: Implicit conversion from data type money to nvarchar is not allowed. Use the CONVERT function to run this query.

I don't understand why when all of the variables are of the money type. I needed to add the values before insert the money value back into the database. Any help would be much appreciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-08 : 09:10:48
Which lines produces the error? The PRINT line?
Change it to PRINT CAST(@BookingCost AS VARCHAR(20))


E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-01-08 : 09:11:11
What is the datatype of booking_cost_no_extras?

Madhivanan

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

godspeedba
Yak Posting Veteran

90 Posts

Posted - 2009-01-08 : 09:14:29
Do'h, when I removed the Print(@bookingcost) it worked, thanks for your help :)
Go to Top of Page
   

- Advertisement -