看來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