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 |
missMac
Posting Yak Master
124 Posts |
Posted - 2009-01-19 : 13:38:34
|
how do I combine two tables?ie i have a table that logs invalid phone numbers entered and another with unprocessed numbers and reason.both have similar columns. ieTable 1: failed columns: ID, number, reasonTable 2: unprocessed numberscolumns: ID, numbers, reasondo i use union all ?thanksMM |
|
revdnrdy
Posting Yak Master
220 Posts |
Posted - 2009-01-19 : 13:49:30
|
Hello;UNION ALL will return duplicate rows. If you have a phone number characterized as unprocessed and invalid (for some reason) then the record will show up twice. Also the tables must be identical in structure (same columns & datatypes).If thats ok then use something like this:SELECT ID, number, reason FROM failedUNION ALLSELECT ID, number, reason FROM [unprocessed numbers]r&r |
|
|
asgast
Posting Yak Master
149 Posts |
Posted - 2009-01-20 : 03:40:45
|
if you don't want duplicate values just use union |
|
|
bjoerns
Posting Yak Master
154 Posts |
Posted - 2009-01-20 : 04:26:36
|
No, asgast, as long as ID or reason is SELECTed, union will still give duplicate phone numbers. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-20 : 08:53:40
|
quote: Originally posted by bjoerns No, asgast, as long as ID or reason is SELECTed, union will still give duplicate phone numbers.
yup thats true. It just looks for distinct combination of id,reason,number values rather than simply distinct of numbers alone |
|
|
|
|
|
|
|