Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Incorrect Syntax with UNION
Message
De
23/11/2008 07:39:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
23/11/2008 07:24:35
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01363694
Message ID:
01363696
Vues:
10
>Hello, I'm trying to create a simple UNION but is not working is displaying the next message:
>
>TITLE: Microsoft Report Designer
>------------------------------
>
>An error occurred while executing the query.
>Incorrect syntax near the keyword 'UNION'.
>
>------------------------------
>ADDITIONAL INFORMATION:
>
>Incorrect syntax near the keyword 'UNION'. (Microsoft SQL Server, Error: 156)
>
>For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.1406&EvtSrc=MSSQLServer&EvtID=156&LinkId=20476
>
>------------------------------
>BUTTONS:
>
>OK
>------------------------------
>
>And this is my UNION:
>
>SELECT IdUsuario, Nombre
>FROM Usuario
>ORDER BY Nombre
>UNION
>SELECT Null, 'All'
>
>How can I solve this?


Correct syntax would be:
SELECT     IdUsuario, Nombre
FROM         Usuario
UNION
SELECT     Null, 'All'
ORDER BY Nombre
However I guess you are trying to do something like this:
select *
from
 (SELECT  top 100 percent  IdUsuario, Nombre
   FROM         Usuario
   ORDER BY Nombre) tmp
UNION
SELECT     Null, 'All'
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform