开发者

i get an error when creating a variable and specifing the collation in sql server 2005

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜