Temp record Insertion technique
I am using sql s开发者_Python百科erver 2008. I have to insert records in temporary table using multiple select statements like below.
Insert into #temp
Select a From TableA
Insert into #temp
Select a From TableB
Insert into #temp
Select a From TableC
Insert into #temp
Select a From TableD
OR
Insert Into #temp
Select A From
(
Select A from TableA
Union
Select B From TableB
Union
Select B From TableC
)K
Please advice which approach should be best or any other and Why?
The two techniques you present are not interchangeable. The UNION operation will remove duplicate values while the individual INSERT operations will not. To get identical results, you'd need to use UNION ALL.
加载中,请稍侯......
精彩评论