Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting Data Type error

Status
Not open for further replies.

DebbieChapman

Programmer
May 25, 2003
26
GB
Can anyone help on this stored procedure, The Proceedure works fine except that it rounds my charge ie if the charge is 3.5 it displays 4, I've tried to conver the @charge to money, but when I do this i get an error which says

Err 257: Implicit Conversion from datatype money to nvarchar is not allowed, Use the CONVERT function to run this query.

CREATE PROCEDURE BS_CustomerBundleAllowances

@CustomerID Char(6),
@Charge int = 0 OUTPUT,
@Mins int = 0 OUTPUT,
@IntMins int = 0 OUTPUT

AS

SET NOCOUNT ON

Begin
Select CustomerID, BoltOnRef, Allowance, Charge, Mins, IntMins into #Allowance
from BS_BundleAllowances
WHERE CustomerID = @CustomerID
End

Begin
UPDATE #allowance
SET Allowance = 0
WHERE (Allowance < 1)
End

Begin
UPDATE #Allowance
SET
Charge = tblBoltOns.Charge,
Mins = tblBoltOns.Mins,
IntMins = tblBoltOns.Int_Mins
From tblBoltOns, #Allowance
WHERE (tblBoltOns.BoltOnRef = #Allowance.BoltOnRef) and (#Allowance.Allowance = 0)
End

SET @Charge = (Select Charge from #Allowance)
SET @Mins = (Select Mins from #Allowance)*60
SET @IntMins = (Select IntMins from #Allowance)*60

Print @Charge
Print @Mins
Print @IntMins

-- View Allowances for each customer
Select * from #Allowance
 
What datatype is tblBoltOns.Charge (not @charge)?

BTW: INTEGER is whole numbers only, that's why the number is rounding. I suggest using DECIMAL(precision,scale). Figure out how many total digits (precision) you are likely to have and how many of those digits will be to the right of the decimal (scale). For example:

1234.56 is DECIMAL(6,2)
12.3456 is DECIMAL(6,4)

-SQLBill
 
I've written some udf and put them in my SQl Server database.Now I need to pass a table's name to a udf in my source.How can I do it.
 
siftal,

You need to start your own thread with a new post.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top