I am trying to write a User Defined Function in SQL Server 2000.
Unfortunately my copy doesnt seem to want to support them.
I have opened the on line help and pasted in the following example
CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters.
(@CubeLength decimal(4,1), @CubeWidth decimal(4,1),
@CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( @CubeLength * @CubeWidth * @CubeHeight )
END
If I run this I get the following error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'FUNCTION'.
Server: Msg 137, Level 15, State 1, Line 8
Must declare the variable '@CubeLength'.
I have tried following Terry Broadbents advice and qualifying the name of the function with the user and even the database but no luck.
I am using SQL 2000 version 8.00.194
If anybody has any ideas, or could possibly cut the example above and run it on their owm machine and see what happens I would be very grateful, as I have a business requirement for which a UDF would be perfect - if only I could get the damn things to work.
Unfortunately my copy doesnt seem to want to support them.
I have opened the on line help and pasted in the following example
CREATE FUNCTION CubicVolume
-- Input dimensions in centimeters.
(@CubeLength decimal(4,1), @CubeWidth decimal(4,1),
@CubeHeight decimal(4,1) )
RETURNS decimal(12,3) -- Cubic Centimeters.
AS
BEGIN
RETURN ( @CubeLength * @CubeWidth * @CubeHeight )
END
If I run this I get the following error:
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near 'FUNCTION'.
Server: Msg 137, Level 15, State 1, Line 8
Must declare the variable '@CubeLength'.
I have tried following Terry Broadbents advice and qualifying the name of the function with the user and even the database but no luck.
I am using SQL 2000 version 8.00.194
If anybody has any ideas, or could possibly cut the example above and run it on their owm machine and see what happens I would be very grateful, as I have a business requirement for which a UDF would be perfect - if only I could get the damn things to work.