Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
igor92128
Starting Member
23 Posts |
Posted - 2011-12-15 : 20:22:30
|
| Hello,I have 2 temp tables that are pulling the same exact columns but have different values in those columns. I want to create a 3rd temp table with the combined values of the other 2 temp tables. Here is some snippets:create table #table1create table #table2create table #combinedTablesinsert #table1select ...from ...where ...--produces a 210 row tableinsert #table2select..from...where...--produces a 100 row tableinsert #combinedTablesselect..from...where...--should produce a 310 row temp tableAlso, UNION doesn't work since it doesn't return the correct number of rows probably due to NULLs in the other tables.Any ideas would be appreciated. I am on SQL 2005.Thanks,Igor |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-12-15 : 20:24:58
|
Use UNION ALL instead of UNION. Or, you could just do two inserts:insert into #CombinedTable select * from #table1;insert into #CombinedTable select * from #table2; |
 |
|
|
|
|
|