I have two tables:
Table 1: Formulas
FormulaId Formula Text
1 [Qty] * [Rect]
2 [Qty] * [Al]
3 [Mt] * [Cat]
You can only do Cross Join. Other joins can be done only with related tables.
You want to use a CROSS JOIN
:
SELECT FormulaId, Formula, ContextId, [Name]
FROM Formula
CROSS JOIN Context
Did you try CROSS APPLY:
select *
from context
cross apply formulas
order by contextid
See SQL Fiddle With Demo
You can use the Cartesian Product of the two tables as follows:
SELECT * FROM Formulas, Context
This would result in M * N
rows.