Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Union and calculated field
Message
From
28/02/2010 02:01:34
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Union and calculated field
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01451565
Message ID:
01451565
Views:
95
I have a union clause like this:
DECLARE @NoSite Integer
DECLARE @NoSite2 Integer
DECLARE @Enabled Bit
DECLARE @NoSite3 Integer
DECLARE @Enabled2 Bit
DECLARE @NoSite4 Integer
DECLARE @Enabled3 Bit
DECLARE @NoSite5 Integer
DECLARE @NoSite6 Integer

SET @NoSite=2
SET @NoSite2=2
SET @Enabled=1
SET @NoSite3=2
SET @Enabled2=1
SET @NoSite4=2
SET @Enabled3=1
SET @NoSite5=2
SET @NoSite6=2

SELECT TOP 40 News.Title_E,News.Title_F,News.Url,News.AddDate AS Date,News.Url2,1 AS Type,
News.NoSite,'' AS Title2
FROM News WHERE News.NoSite=@NoSite
UNION
SELECT TOP 40 Event.Title AS Title_E,Event.Title AS Title_F,Event.Url,Event.AddDate AS Date,
convert(char(74),'') AS Url2,2 AS Type,Event.NoSite,'' AS Title2
FROM Event
LEFT JOIN Province ON Event.NoProvince=Province.Numero
WHERE Event.NoSite=@NoSite2 AND Event.Enabled=@Enabled
I obtain "The text data type cannot be selected as DISTINCT because it is not comparable.". This is in regards to the syntax where the Url2 field does not exist in the Event table. What would be the proper syntax to have a union with the Event table considering that News.Url2 is char(74)?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform