Sam332
Sam332

Reputation: 67

SQL Server: Combine two unrelated tables

I have two tables that don't have any relationship, I want to create a view that has a new Key column that can be used.

StoreTable:

StoreID     StoreName
----------  -------------
1           Store1
2           Store2
3           Store3

StoreStageTable:

StageID     StageDesc
----------  -------------
1           Pre
2           WorkInProgress
3           Completed

Expected results would be for each StoreName will be combined with each row from the StoreStageTable.

So Store1 will have Store1_Pre and Store1_WorkInProgress and Store1_Completed.

How can I do that?

Upvotes: 0

Views: 49

Answers (1)

bracko
bracko

Reputation: 372

You are searching a cartesian join. It means combine rows with other table rows.

SELECT st.*, ss.*
FROM StoreTable st
CROSS JOIN StoreStageTable ss --there is no condition on CROSS join!

Upvotes: 2

Related Questions