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