SQL Server Management Studio 错误:UserDefinedFunction 的脚本失败 [英] SQL Server Management Studio Error : Script failed for UserDefinedFunction
问题描述
我正在使用 SSMS 处理本地和远程 SQL Server 实例.我创建了一个小函数,如:
I'm working on a local and a remote SQL Server instance with SSMS. I create a tiny function like:
create function ufnTestFunc ()
returns int
begin
return 1
end
当我尝试修改"它或选择脚本功能为 -> 更改"时,我收到如下错误:
When I try to 'modify' it, or choose 'script function as -> alter', I get an error like:
UserDefinedFunction 'dbo.ufnTestFunc' 的脚本失败.(Microsoft.SqlServer.Smo)
Script failed for UserDefinedFunction 'dbo.ufnTestFunc'. (Microsoft.SqlServer.Smo)
- UserDefinedFunction 'ufnTestFunc' 的 TextHeader 中的语法错误.(Microsoft.SqlServer.Smo)
- Syntax error in TextHeader of UserDefinedFunction 'ufnTestFunc'. (Microsoft.SqlServer.Smo)
这也发生在已经存在的函数上.可能是什么原因?
This also happens on already existing functions. What may be the reason?
注意事项:
- 所有功能都按预期工作
- 我可以毫无问题地将函数编写为创建".
- 它与评论无关,因为测试函数中没有评论
- 远程服务器上的不同数据库也会发生同样的情况
本地服务器:
Microsoft SQL Server Express 版(64 位)- 10.50.2500.0
Local Server:
Microsoft SQL Server Express Edition (64-bit) - 10.50.2500.0
远程服务器:
Microsoft SQL Server 网络版(64 位)- 10.50.1600.1
Remote Server:
Microsoft SQL Server Web Edition (64-bit) - 10.50.1600.1
SSMS:
Microsoft SQL Server Management Studio 10.50.2500.0
Microsoft Data Access Components (MDAC) 6.1.7601.17514
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 2.0.50727.5448
推荐答案
和前面提到的一样,但有一点不同.
Ok like someone mentioned before, but with a little difference.
问题在于 AS
关键字.虽然函数内容前的AS
关键字是可选的,但是没有它SSMS就不能处理函数.他们工作,但制造麻烦.这是一个错误,在 BOL 中的任何地方都没有提到.
The problem is the AS
keyword. Although the AS
keyword before the function content is optional, SSMS can't handle functions without it. They work, but make trouble. It's a bug and not mentioned anywhere in the BOL.
我通常使用 AS
关键字,但这次 DB 来自以前没有使用它的编码员.在我的测试函数中,我也没有使用它来使函数尽可能小.
I normally use the AS
keyword, but this time the DB is from a previous coder, who didn't use it. In my test function I also didn't use it to make the function as small as possible.
这篇关于SQL Server Management Studio 错误:UserDefinedFunction 的脚本失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!