Data Matching

  • Hi All.

    I have a table which has following colums with more than 10 million records.

    COLA

    COLB

    Now situation is I have some 3000 rows in excel with COLA format mentioned with above table. I need to check the occurence of every row in excel file to our actual sql table as below format.

    COL A No. of occurence with actual sql table

    dffrddd 10

    BRdertt 2

    bt45fcdw 5

    I can see with count(*) I can count the no. of occurences in actual table but not sure how to fetch the corresponding value for COLA. I can define the logic to fetch the output as above mentioned format but not very much handy with T-sql scripting.

    Could anyone please help me asap.

    Thanks in advance.

    Regards,

    Austin

  • If this is a one time or very infrequent requirement I suggest using the Excel work book and not T-SQL. Refer to the following from Microsoft on ways to count various items.

    http://office.microsoft.com/en-us/excel-help/summing-up-ways-to-add-and-count-excel-data-HA001126627.aspx?CTT=1&origin=EC001022986

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Ron- Thanks for the reply.

    How do you suggest to cross check 3000 excel records with more than 10 million records with sql db table.

    My logic goes with sql script.

    1. Create a temporary table with already mentioned sql COLA field only.

    2. Insert all 3000 excel rows. (Insert statements already prepared)

    3. Create another temporary table to keep the final output.

    4. Define a cursor for temp table and cross check against each record with actual table and generate the result and insert the record in 2nd temp table as below format.

    Rows from excel table kept in temptable Totalno of occurences on actual sql table

    rtftwer 4

    btrredf 10

    --

    -

    till last row with temp table.

    Not very much handy with sql statements.

    Can anyone please help me?

    thanks

    Austin

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply