在 sql server 2005 中创建变量并指定排序规则时出现错误

发布于 2024-09-27 04:37:14 字数 774 浏览 1 评论 0原文

当我尝试这个时:

DECLARE @var nvarchar(500) collate Arabic_BIN

我得到了:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'collate'.

这是完整的代码,它可以工作,我不知道如何,但给我它的人已经成功使用它

CREATE FUNCTION fn_RemoveTashkeel (@InputString nvarchar(2300) )

RETURNS nvarchar(2300)

AS
BEGIN
   DECLARE @OutputString nvarchar(2300) COLLATE Arabic_BIN 
   DECLARE @TashkeelChr char(8) COLLATE Arabic_BIN 
   DECLARE @feed int
   SET @OutputString=@InputString
   SET @TashkeelChr='ًٌٍَُِّْْْْْ'
   SET @feed=1
 WHILE @feed<=LEN(@TashkeelChr)
   BEGIN
    SET @OutputString=REPLACE(@OutputString,SUBSTRING(@TashkeelChr,@feed,1),'')
    SET @feed=@feed+1
   END
   RETURN(@OutputString)
END

when i tried this:

DECLARE @var nvarchar(500) collate Arabic_BIN

i got that:

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'collate'.

that is the full code, it works, i do not know how but the person who give it to me have used it successfully

CREATE FUNCTION fn_RemoveTashkeel (@InputString nvarchar(2300) )

RETURNS nvarchar(2300)

AS
BEGIN
   DECLARE @OutputString nvarchar(2300) COLLATE Arabic_BIN 
   DECLARE @TashkeelChr char(8) COLLATE Arabic_BIN 
   DECLARE @feed int
   SET @OutputString=@InputString
   SET @TashkeelChr='ًٌٍَُِّْْْْْ'
   SET @feed=1
 WHILE @feed<=LEN(@TashkeelChr)
   BEGIN
    SET @OutputString=REPLACE(@OutputString,SUBSTRING(@TashkeelChr,@feed,1),'')
    SET @feed=@feed+1
   END
   RETURN(@OutputString)
END

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

林空鹿饮溪 2024-10-04 04:37:14

您不在变量声明中设置排序规则。根据 MSDN 文档:

整理

是一个子句,可应用于数据库定义或列定义以定义排序规则,或应用于字符串表达式以应用排序规则转换。

换句话说,您可以在数据库级别设置排序规则,作为表列定义的一部分或在 SELECT 语句中。

有关详细信息,请参阅 MSDN 文档

You don't set collation in a variable declaration. Per the MSDN documentation:

Collate:

Is a clause that can be applied to a database definition or a column definition to define the collation, or to a character string expression to apply a collation cast.

In other words, you set collation at the database level, as part of a table's column definition, or in SELECT statements.

See the MSDN documentation for more information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文