[英]Insert all the values from one table to each row in another table
I have two tables我有两张桌子
SLNO
1
2
3
4
5
6
and和
MonthDate
2014-1-1
2014-2-1
2014-3-1
How can I merge these two table into one table to get the output like this.如何将这两个表合并到一个表中以获得这样的输出。
SLNO MonthDate
1 2014-1-1
1 2014-2-1
1 2014-3-1
2 2014-1-1
2 2014-2-1
2 2014-3-1
3 2014-1-1
3 2014-2-1
3 2014-3-1
And so on...等等...
INSERT INTO Table3
SELECT SLNO , MonthDate
Table1 CROSS JOIN Table2
OR或者
INSERT INTO Table3
SELECT SLNO , MonthDate
Table1 CROSS APPLY Table2
用这个 :
Select * from t1,t2 order by t1.SLNO
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.