在 sql server 2005 中创建变量并指定排序规则时出现错误
当我尝试这个时:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不在变量声明中设置排序规则。根据 MSDN 文档:
整理:
换句话说,您可以在数据库级别设置排序规则,作为表列定义的一部分或在 SELECT 语句中。
有关详细信息,请参阅 MSDN 文档。
You don't set collation in a variable declaration. Per the MSDN documentation:
Collate:
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.