看来SQL Server CE不喜欢COALESCE
与我的列。SQL Server CE引发错误使用COALESCE时参数无效
如果我的查询有COALESCE(ep.value, '') as id
,与
我使用(case ep.value when null then '' else ep.value end
)试图
参数无效查询失败,但随后我得到
其他错误NTEXT
等有谁知道另一种方式将空值转换为非空值?
UPDATE:
完整的查询是相当复杂,需要很长的时间来解释,但在这里它是为好奇。
SELECT COALESCE(ep.value, '') as domainId , [p].[id], [p].[firstName], [p].[middleName], [p].[lastName], [p].[isDeleted], ... FROM Patient p INNER JOIN PatientOrganisation po on p.id = po.patientFk left join extendedproperty ep on ep.entityId = p.id left join (select sgu.id, sgu.unitFk from StaffGroupUnit sgu where sgu.staffGroupFk = '3d364f5b-b5ff-456a-bf33-d8b48bf195b2' and sgu.isDeleted = 0) as bat on bat.unitFk = po.unitFk where p.isDeleted = 0 and po.isDeleted = 0 AND COALESCE(ep.metadatafk,'55b009d5-cead-4b62-ad04-526b57a02ed2')='55b009d5-cead-4b62-ad04-526b57a02ed2' and COALESCE(ep.isdeleted,0)=0 AND (not exists(select 1 from staffgroupunit sgu where sgu.staffGroupFk = '3d364f5b-b5ff-456a-bf33-d8b48bf195b2' and sgu.isDeleted=0) OR bat.id IS NOT NULL) order by p.lastName, p.firstName
现在是的,我知道这个查询是可怕的,我已经通过删除它的一些部分来解决问题。真正有趣的是,这个查询将主要工作。当“参数无效”失败时,我可以使用Visual Studio或Management Studio运行完全相同的查询,并且它可以正常工作。
我们使用CE 3.5,因为我们的产品之一是Windows Mobile。我怀疑这只是CE中的一个错误,升级将会解决。
干杯
您可以编辑您的问题,包括你的整个select语句? – 2012-07-24 03:22:06
您使用的是哪个版本的CE? – 2012-07-24 03:28:33