create a view that has UNION ? | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

create a view that has UNION ?

SQL2000 if I can’t create a view can I create a store procedure ? SELECT ………
FROM ……..
WHERE ……
Union
SELECT ………
FROM ……..
WHERE ……
Union
SELECT ………
FROM ……..
WHERE ……
May the best cheaters win
Im not sure what the question is?
There are no problems using UNION in a standard view. A stored procedure can use them too. What error are you getting ?
You have to have the same number of columns defined by expressions of the same datatype in each select list. You also have to alias expression that is not simple column name. Also if you have two columns with the same name (comming from diferent joined tables) you have to use alias(es) to distinguish them.
I use Enterprise Manager to create view and it won’t let me save the view When I use save it said "View definition includes no output columns or includes no items in the From Clause" but I run it is fine. The question should be would please show me how to create view without using the Enterprise Managment May the best cheaters win
Use Query Analizer to create view like this not Enterpize Manager.

Copy query that defines view to clipboard then past it to query analizer. After that add aliases to columns, i guess you have problem with aliases.
I got it working this way I create a view in EM add any table save it then I edit that and paste my sql query in and save. then it is working. Thanks all May the best cheaters win
]]>