Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Union and calculated field
Message
De
28/02/2010 02:01:34
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Union and calculated field
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01451565
Message ID:
01451565
Vues:
96
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform