Tuesday, December 9, 2014

A temporary SQL table

Sometimes we might require to have a temporary SQL table without physically creating it in database.


Following is a very simple example.

SELECT 0 AS ID, 'Fruits' AS Name UNION ALL
SELECT 1 AS ID, 'Vegetables' AS Name UNION ALL
SELECT 2 AS ID, 'Exercise' AS Name UNION ALL
SELECT 3 AS ID, 'Meditation' AS Name UNION ALL
SELECT 4 AS ID, 'Positive Thinking' AS Name UNION ALL
SELECT 5 AS ID, 'Enough Sleep' AS Name


I once needed it in SSAS Data Source View to define Target and Red-Line for a cube measure. 

 Cheers :)