Search This Blog

Thursday, September 10, 2009

SQL, Union Operator

Sometimes you need to to combine several tables together, and make them a bigger table. Like combine January data (table) with February data (table).

But what if you do not want to create this big table in the database? You can use UNION operator.

SELECT 1, 'January' UNION ALL
SELECT
2, 'February' UNION ALL
...
SELECT
12, 'December'

Or make them a stored procedure.

http://stackoverflow.com/questions/1376361/returning-data-without-accesing-a-table

No comments: