SQL Server 2012:关键字“order”附近的语法不正确

时间:2014-01-27 19:02:56

标签: sql sql-server-2012

运行此查询时出现此错误...

select *, stuff(PartNumber,1,3,'') 
from products.products 
where  isnumeric(stuff(partNumber,1,3,'') 
order by cast(Stuff(partNumber,1,3,'')As Float)

有什么想法吗?

谢谢!

3 个答案:

答案 0 :(得分:4)

where声明不完整:

where  isnumeric(stuff(partNumber,1,3,'')) = 1
-----------------------------------------^

答案 1 :(得分:1)

看起来你错过了一个括号:

此:

where  isnumeric(stuff(partNumber,1,3,'') 

应该是:

where  isnumeric(stuff(partNumber,1,3,'')) 

答案 2 :(得分:1)

首先是缺少闭括号“)”,另一个是当输入表达式求值为有效数值数据类型时,必须在where子句中指定isnumeric返回1。

   `    select *, stuff(PartNumber,1,3,'') 
        from products.products 
      where  isnumeric(stuff(partNumber,1,3,'')) =1
     order by cast(Stuff(partNumber,1,3,'') As Float)
  `