I have successfully created the following function on the SQL database.
CREATE FUNCTION [dbo].[maximum_time]
(
@TotalLengthofRecords REAL
)
RETURNS FLOAT
AS
BEGIN
RETURN
CASE
WHEN @TotalLengthofRecords > 3600 THEN 3600
ELSE @TotalLengthofRecords
END
END
Reviewing the objects in Microsoft SQL Server Management Studio, it seems that the user-defined function has been successfully created in the System Database -> master
. However, the function is not appearing within the project database.
Whenever I try to call the function using the following code:
SELECT
A.*,
[dbo].[maximum_time]([TotalLengthofRecords_MAX])AS [TotalLengthofRecords_MAX]
INTO [dbo].[BunkerAISFinal_V7]
FROM [dbo].[BunkerAISFinal_V6] AS A;
The system will throw up the following error:
Cannot find either column "dbo" or the user-defined function or aggregate "dbo.maximum_time", or the name is ambiguous.
How do I solve this problem? Is there a way of creating the function in a particular database name?