首页 > 数据库 > mysql教程 > sql server 标量值函数实例与不能调用原因分析

sql server 标量值函数实例与不能调用原因分析

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-07 17:47:32
原创
1514 人浏览过

sql server 标量值函数实例与不能调用原因分析,MS SQL 标量值函数,应该在函数前面加上 \"dbo.\",否则会报 “不是可以识别的 内置函数名称”错误

sql server 标量值函数实例与不能调用原因分析
--标量值函数

set ansi_nulls on
go
set quoted_identifier on
go
-- =============================================
-- author:
-- create date:
-- description:
-- =============================================
create function
(
-- add the parameters for the function here

)
returns
as
begin
-- declare the return variable here
declare

-- add the t-sql statements to compute the return value here
select =

-- return the result of the function
return

end


用 ms sql 标量值函数,应该在函数前面加上 "dbo.",否则会报 “不是可以识别的 内置函数名称”错误。例如

  

  declare @whichdb tinyint;
    select @whichdb = user_getwhichdb(1);--看看是哪个的

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

--标量值函数

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

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
php - prepare与sql的开销?
来自于 1970-01-01 08:00:00
0
0
0
sql文件
来自于 1970-01-01 08:00:00
0
0
0
打印sql语句
来自于 1970-01-01 08:00:00
0
0
0
sql优化or
来自于 1970-01-01 08:00:00
0
0
0
mysql - sql报错原因?
来自于 1970-01-01 08:00:00
0
0
0
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板