SQLServer 在存储过程中找不到我的用户定义函数 [英] SQLServer cannot find my user defined function function in stored procedure

查看:72
本文介绍了SQLServer 在存储过程中找不到我的用户定义函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一定有一些权限错误,但我不知道是怎么回事.以下代码已简化,但我什至无法使其正常工作

I must have some permissions wrong, but I can't figure out how. The following code is simplified but I can't even get this to work

CREATE FUNCTION ufTest 
(
    @myParm int
)
RETURNS int
AS
BEGIN
    DECLARE @Result int

    SELECT @Result = @myParm + 1

    RETURN @Result
END
GO

然后我只想能够从存储过程中调用该函数:

Then I just want to be able to call the function from a stored procedure:

CREATE PROCEDURE dbo.[uspGetGroupProfileService]
@id        int
AS
BEGIN
    SET NOCOUNT ON;
    DECLARE @otherId int;
    SET @otherId = dbo.ufTest(@id);
END

SQLServer 一直告诉我它找不到 dbo.ufTest.它显示在 [DB]\Programmability\Functions\Scalar-valued Functions 下,但我不知道如何使用它.

SQLServer keeps telling me that it can't find dbo.ufTest. It shows up under [DB]\Programmability\Functions\Scalar-valued Functions but I can't figure out how to use it.

有人知道我做错了什么吗?

Anybody have any idea what I'm doing wrong?

编辑

如以下所选答案所示,您不能总是信任 SSMS Intellisense.除了尝试执行脚本之外,您可以尝试的一件事是使用 CTRL + SHIFT + R 强制刷新智能感知

As indicated by the selected answer below, you can't always trust the SSMS Intellisense. One thing that you can try, other than just trying to execute the script, is forcing an Intellisense refresh with CTRL + SHIFT + R

https://blog.sqlauthority.com/2013/07/04/sql-server-how-to-refresh-ssms-intellisense-cache-to-update-schema-changes/

推荐答案

为我工作.

试试 CREATE FUNCTION dbo.ufTest ...

我假设您的默认架构不能是 dbo 并且它以不同的架构结束.否则我能想到的唯一解释是您可能需要授予权限.

I assume your default schema can't be dbo and it's ending up in a different schema. Otherwise the only explanation I can think of is you might need to grant permissions on it.

这篇关于SQLServer 在存储过程中找不到我的用户定义函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆