创建变量并在sql server 2005中指定排序规则时出现错误 [英] i get an error when creating a variable and specifing the collation in sql server 2005
问题描述
当我尝试这样做时:
DECLARE @var nvarchar(500) collate Arabic_BIN
我明白了:
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
推荐答案
您不•在变量声明中设置排序规则。根据MSDN文档:
You don't set collation in a variable declaration. Per the MSDN documentation:
整理:
是可用于数据库定义或列定义以定义归类的子句,或可应用于字符串表达式以应用归类强制转换的子句。
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.
换句话说,您可以在数据库级别或表的列定义中或在SELECT语句中设置排序规则。
In other words, you set collation at the database level, as part of a table's column definition, or in SELECT statements.
请参见 MSDN文档以获取更多信息。
See the MSDN documentation for more information.
这篇关于创建变量并在sql server 2005中指定排序规则时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!