运行SQL查询时出错 [英] Error while running a SQL query

查看:98
本文介绍了运行SQL查询时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT distinct(a.customerid),a.*,b.* from nop_customer a,nop_customerattribute b where a.customerid = b.customerid and a.email like @Value + ''%'' or a.username like @Value + ''%'' or (b.[key] like ''FirstName'' and b.value like @Value + ''%'')



当我在数据库中触发此查询时,出现此错误:
第421条消息,状态16,状态1,过程Nop_GetCustomerAttributesBySearch,第17行
无法将xml数据类型选择为DISTINCT,因为它不可比较.



When i fire this query in the database i get this error:
Msg 421, Level 16, State 1, Procedure Nop_GetCustomerAttributesBySearch, Line 17
The xml data type cannot be selected as DISTINCT because it is not comparable.

推荐答案

由于XML数据类型不可比较,因此无法将其选择为DISTINCT."
错误本身是不言自明的!

您正在尝试将DISTINCT关键字用于数据类型为"XML"的字段.
SQL不允许在该字段中使用DISTINCT,从而导致错误.

如果实际上需要DISTINCT(基于它的形成方式可以忽略),则您需要以其他方式形成查询.当有重复项时,尝试根据特定字段使用MAX,TOP或此类.
"The xml data type cannot be selected as DISTINCT because it is not comparable."
Error itself is self explanatory!

You are trying to use DISTINCT keyword with a field that has a datatype of ''XML''.
SQL does not allow DISTINCT with that field and thus the error.

If actually DISTINCT is needed (based on the way it is formed looks like can be left out), then you need to form the query someother way. Try to use a MAX, TOP or so based on certain field when duplicates are there.


这篇关于运行SQL查询时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆