Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to use UNION while inserting in a table using SELECT clause from many tables in SQL Server 2000
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COJust get rid of the parentheses and the query you posted should work in principle assuming it returns a union compatible result (though it would do 2 cartesian joins which probably isn't the desired semantics). And of course the result would need to be compatible with the `insert` statement which could only be the case if all 4 tables involved only had 1 column. Frankly the example code you posted seems quite nonsensical. Can you explain why/where you are using `order by` here as that doesn't even feature anywhere in it?
      singulars
    2. COit surprised me as well. For simple inserts like CREATE TABLE BB(NAME VARCHAR(200)) INSERT INTO BB SELECT NAME FROM FS77..S_ORG_EXT WHERE NAME LIKE '%Hos%' UNION SELECT NAME FROM FS77..S_ORG_EXT WHERE NAME LIKE '%Com%' it works fine, but for the complex one i m using with different SQLs retruning same columns in select and different WHERE clauses using UNION, IT THrows an error saying Server: Msg 104, Level 15, State 1, Line 1 ORDER BY items must appear in the select list if the statement contains a UNION operator.
      singulars
    3. COBefore using UNION, using individual INSERT Using SELECT, i am using some criteria in join where i am using ORDER BY COL_NAME without using COL_NAME in SELECT on a join, with UNION, it is creating problem which i m not able to understand.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload