sql-server - Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnCustomDate", or the name is ambiguous
问题描述
I working on a basic function and tried executing but it doesn't work and throws the below error "Cannot find either column "dbo" or the user-defined function or aggregate "dbo.fnCustomDate", or the name is ambiguous."
Below is the Function:
CREATE FUNCTION [dbo].[fnCustomDate]
(
@DateFormat AS DATETIME
)
RETURNS VARCHAR (MAX)
AS
BEGIN
RETURN DATENAME(DW,@DateFormat) + ' ' +
DATENAME(D,@DateFormat) +
CASE
WHEN DAY(@DateFormat) IN (1, 21, 31) THEN 'st'
WHEN DAY(@DateFormat) IN (2, 22) THEN 'nd'
WHEN DAY(@DateFormat) IN (3, 23) THEN 'rd'
ELSE 'th'
END + ' ' +
DATENAME(M,@DateFormat) + ' ' +
DATENAME(YY,@DateFormat)
END
GO
Trying to execute it on a table for date column:
Select [dbo].[fnCustomDate](column name)
from [dbo].[tablename]
解决方案
“找不到列“dbo”或用户定义的函数或聚合“dbo.fnCustomDate”,或者名称不明确。”
未找到该函数时返回此错误。简单的检查事项:
您是否连接到正确的数据库?
函数拼写是否正确?
架构 dbo 是否存在?
我的函数在 dbo 模式中吗?
注意:该函数没有任何错误,或者您在提供的示例中如何调用它。
推荐阅读
- reactjs - 如何创建具有动态 url 前缀的链接?
- c - 加载共享库时出错,无法打开共享对象文件:没有这样的文件或目录(hiredis)
- node.js - 覆盖冲突文件以链接 node.js 时出错
- scala - 在 Scala 中,交错大量迭代器的最简单方法是什么?
- echo - 在 Katalon Recorder 中使用 storeValue 和 echo
- c - 排序算法不通过
- pandas - Pandas:获取正好有一个 0 的行
- php - 无法将 PHP 变量传递给 Epayment 网站的隐藏输入
- docker - 在 Windows 上构建容器时,Docker 构建变量始终为空
- xerces - 为什么我得到 [topic-reader] [DOTJ013E][ERROR] 无法解析 DITA-OT 3.0.4 中的引用文件 'xxx'