2016-06-13 103 views
1

這是我的SQL查詢。執行此查詢時,我得到以上錯誤從字符串轉換爲uniqueidentifier時轉換失敗sql server 2014

WITH Results_CTE AS (select Top 20 ROW_NUMBER() OVER (ORDER BY KeyId desc) AS SNo,* from(select * from ( select ps.Id as KeyId,dps.Id as SettingId,dps.DocumentType,dps.DocumentProcessingType,null as Description,null as Link 
      from [ParttimerSalary] ps inner join [ParttimerEmployee] pe on pe.Id = ps.ParttimerEmployeeId 
      inner Join [DocumentProcessingSetting] dps on dps.Step = ps.Step and dps.KeyId = pe.ParttimerType and 
      (dps.RoleId = 'e218e9e0-d51d-45b4-9380-77f43ac50f0d' or dps.UserId = '1967681a-7d64-486e-99a8-4b58746cef81') and dps.DocumentType = 2 union all 
      Select 'Incident/service is assigned for you' as [Description],'#/it/incidentsupport/' as Link,0 as Id,0 as SettingId,0 as DocumentType,0 as DocumentProcessingType from Incident where IncidentStatus = 2 and SupportById = '1967681a-7d64-486e-99a8-4b58746cef81' 
      )wrapped) listing ORDER BY KeyId desc) SELECT * FROM Results_CTE WHERE SNo >= 0 AND SNo <=20 

任何幫助,將不勝感激。謝謝

回答

1

在使用Union時,所有數據類型都應該在選擇元素中匹配。

  • ps.Id由於KeyId是唯一標識符,而'事件/服務爲您指定',因爲[Description]是錯誤原因的字符串。
0

其實,我已經改變了工會的關鍵字後,從表中選擇列,如工會期間的訂單,我們需要管理秩序,數據類型等的兩個表 的領域和問題得到解決。 無論如何謝謝

相關問題