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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MASSIVE DB varying results

Author  Topic 

jarndt81
Starting Member

1 Post

Posted - 2011-01-13 : 17:45:36
I have a CSV file (db#1) with over 440,000 records with about 13 fields of data... and I'm relatively new to SQL. I need to compare a list of omitted words from db#2 (about 65 of them) to the account name in db#1 and separate into two places: the file where these scrub words are present and the file where these scrub words are not present. I've succeeded with one and partially succeeded with the other, but error checking is a pain within itself. To further complicate matters, any time I've tried exporting the results (using MS Access 2007), I get an error that the file is too large (it cuts off at about 65000 records).

Here is what I have that returns the records without the scrub words (this one is accurate, I think):

SELECT *
FROM TestRun
LEFT JOIN Sheet1 ON TestRun.[Account Name] Like '*'+Sheet1.Field1+'*'
WHERE Sheet1.Field1 IS Null
ORDER BY TestRun.[Acct Num 10digit];

Here's what I have that works, but not in the way I want it to (I need to return all rows without duplicates, but can't get that to work):

SELECT DISTINCT TestRun.[Acct Num 10digit]
FROM TestRun
INNER JOIN Sheet1
ON TestRun.[Account Name] LIKE '*'+Sheet1.Field1+'*'
ORDER BY TestRun.[Acct Num 10digit];

The combined output number of records from these two queries returns the total number of records I have. I think I may be able to take the results of the second query and do an equi join with the original table. Am I going about this all wrong and there's really an easier way to accomplish this? Also, the first query results in appr 410,000 records. Is there a way to export it that I'm not thinking of? Both the export wizard and the SELECT INTO statement return partial results.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-16 : 05:45:08
so not fully clear. Can you illustrate with some sample data what you mean by duplicate and which data you're missing in query 2?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -