I'm having trouble calling a function that I have created. Any help would be most appreciated. Here is the function:
CREATE FUNCTION myFunction
(
@T DECIMAL(38,14),
@R DECIMAL (38,14),
@S DECIMAL(38,14)
)
RETURNS DECIMAL(38,14)
AS
BEGIN
RETURN
SQRT(
ABS(
(@T/(@R-1))-((@R/(@R-1))*(@S*@S))))
/@S
END
GO
I then need to use this function on a table. This is to fill the 'CV' column. This needs to work on the following columns:
@T Decimal (38,14) as SumSqJT
@R Decimal (38,14) as "SumObs"
@S Decimal (38,14) as "AvJT"
EDIT:
This is the function I've then used
Use [Neutral Month 20132014 ALL]
SELECT
dbo.MyFunction(SumSqJT1, SumObs, AvJT) AS FunctionResult
FROM
Essex_Data_1314
WHERE
SumObs > 1
This creates the list of figures, however I need to update column CV in table Essex_Data_1314 not just create a list of figures. How do i do that?
This has now been solved to be this:
Use [Neutral Month 20132014 ALL]
UPDATE
Essex_Data_1314
SET
CV = dbo.MyFunction(SumSqJT1, SumObs1, AvJT)
Note: It is important to have everything as either a DECIMAL or a NUMERIC datatype. Otherwise conversion errors occur.
Thanks for the help JohnnyBell.
Cheers.