Home Forums SQL Server 7,2000 T-SQL Error/problems with using UNION in combo with CURSOR RE: Error/problems with using UNION in combo with CURSOR

  • A union generates more rows not more columns. Does this return what you expect?

    SELECT col1, col2, col3 FROM Table1 WHERE (EXISTS (SELECT col5 FROM Table2 WHERE col1 =c5))

    UNION ALL

    SELECT col4, col5, col6 FROM Table2

    There will only be 3 columns returned from this statement. Their headings would be col1, col2, col3. The data for col4, col5, col6 will be there but the first heaing will be used.