SELECT TOP 5
Notices.Id,
NoticeLoc.Notices_Id,
Loc.Id as Loc_Id,
CAST(Notices.Text AS TEXT) as Text,
CAST(Notices.Title AS TEXT) as Title,
Notices.CDate as RDate
FROM NoticeLoc
JOIN Notices ON NoticeLoc.Notices_Id=Notices.Id JOIN Loc ON NLoc.Loc_Id=Loc.Id WHERE Loc_Id IN (1)
UNION
SELECT TOP 5
Notices.Id,
'',
'',
CAST(Notices.Text AS TEXT) as Text,
CAST(Notices.Title AS TEXT) as Title,
Notices.CDate as RDate
FROM NoticeC
JOIN Notices ON NoticeC.Notices_Id=Notices.Id WHERE C_Id=110 AND CDate BETWEEN '10/01/2011' AND '07/14/2025' ORDER BY RDate desc
我試圖使用MSSQL 2個的結果集之間進行聯合,但是我收到以下錯誤:SQL聯盟未能
Msg 421, Level 16, State 1, Line 1 The text data type cannot be selected as DISTINCT because it is not comparable.
我必須保持這些領域的文本字段。
我該如何解決這個問題,歡呼聲。
你能格式化你的SQL查詢嗎?沒人能讀到。 – Cylindric 2012-04-05 10:36:53
爲什麼你不能使用'VARCHAR(MAX)'而不是'TEXT'有什麼原因?你是在鑄造他們.. – Seph 2012-04-05 11:06:18