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 |
|
duanecwilson
Constraint Violating Yak Guru
273 Posts |
Posted - 2010-03-11 : 10:56:22
|
| I have written this query every conceivable way. [SMS-AppData] has about 3 million records. The other table has about 300 and is a lookup table. I just want to retrieve the appropriate AppName There are NULLs in both columns I am JOINING on. I thought this would be minutes, not hours to figure out. It's a simle lookup.I have simplified it here. I am getting 10,000,000 rows. I have tried RIGHT JOINS and LEFT JOINS. I want to look up the AppName in commonapp. I want to return all records in [SMS-Appdata] whether or not there is a name. After I perfect it, I will include some columns from [SMS-Appdata]SELECT commonapp.AppName FROM CommonAppRIGHT JOIN [SMS-Appdata] ON [SMS-Appdata].detectstring = [CommonApp].ExeNameDuane |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-03-11 : 11:06:27
|
Maybe we can help if you can provide some sample data.Not the 3 million records but some records to show what we have.Not the 300 records but some of them so we can see what is causing the problem.Are there duplicates in commonapp or are there 300 distinct values? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
duanecwilson
Constraint Violating Yak Guru
273 Posts |
Posted - 2010-03-11 : 16:39:04
|
| Thanks for your response. I discovered a couple things in addition to the fact that the smaller table did have some duplicates, which would explain some of it. But I think I have gone through this before and still am not quite sure how to write queries with JOINs that don't end up with duplicate columns, even simple lookups without duplicate data.Duane |
 |
|
|
|
|
|