Cause Analysis of SQL Server Scalar Value Function instances and unavailability

Source: Internet
Author: User
SQL Server Scalar Value Function instance and reason analysis cannot be called. If MSSQL scalar value function is used, add dbo before the function. Otherwise, the error "not a recognizable built-in function name" is reported.

SQL server Scalar Value Function instance and can not call the Cause Analysis, ms SQL scalar value function, should be added in front of the function \ "dbo. \ ", otherwise the error" not a recognizable built-in function name "will be reported

Cause Analysis of SQL server Scalar Value Function instances and unavailability
-- Scalar Value Function

Set ansi_nulls on
Go
Set quoted_identifier on
Go
-- ===================================================== ======
-- Author:
-- Create date:
-- Description:
-- ===================================================== ======
Create function
(
-- Add the parameters for the function here
<@ Param1, sysname, @ p1>
)
Returns
As
Begin
-- Declare the return variable here
Declare <@ resultvar, sysname, @ result>

-- Add the t-SQL statements to compute the return value here
Select <@ resultvar, sysname, @ result >=< @ param1, sysname, @ p1>

-- Return the result of the function
Return <@ resultvar, sysname, @ result>

End


With the MS SQL scalar function, you should add "dbo." Before the function, otherwise the error "not a recognizable built-in function name" will be reported. For example

Declare @ whichdb tinyint;
Select @ whichdb = user_getwhichdb (1); -- check which one

========================================================== ==========

-- Scalar Value Function

Alter function [dbo]. [user_getwhichdb]
(
@ Userid int = 0
)
Returns tinyint
With execute as caller
As
Begin
Declare @ whichdb tinyint;
Set @ whichdb = 1;
If @ userid> = 115098
Set @ whichdb = 2;

Return (@ whichdb );
End

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.