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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Conditional Update/Insert

Author  Topic 

dbleyl
Starting Member

21 Posts

Posted - 2001-04-11 : 10:25:30
Hi,

I've got a resultset I want to add to a table: ZIP|COUNTY|COUNT. I want to add a row if the ZIP doesn't exist in the table, and if it does, I want to add the COUNT value to the COUNT in the table.
To complicate things, to produce the resultset, I must perform a join. I have 100 resultsets that return about 1 million records each.
I've considered inserting a resultset into the table, then running a GROUP BY ZIP/SUM(COUNT), but this would have to be done 100 times. Seems like a waste. Currently, the client-side opens the table, retrieves the rs, and seeks each record.
If nomatch, it adds the record to the table, if a match is found it updates the COUNT field. I'm looking for a server-side/TSQL solution.

Any ideas?

   

- Advertisement -