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)
 A Better Stored Procedure?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-08 : 09:31:52
Jonathan writes "Developers,

I have a piece of crap Access 95 database that I have the dubious task of converting into a new, more robust, (enough adjectives yet) SQL Server 2000 database. Now, I am trying to write a stored procedure that looks at the data that exists in the new SQL database (A) and compare it to another table that I have (B). I have the logic down, but the whole cursors are a little much for me. Here is the elementary logic:

- Use a cursor to open the full recordset from A
- While there are still records left in A
- Use the unique key in A to find a record in B
- If the record exists in B, check to see if the data element is the same
- If same, OK
- Else, not same change B to A
- Else, if not in B - add to A
- Loop for ever

So, I am sure that you understand this. My problem was trying to use the @@FETCH statement and reference recordset A and not B. Is there a better way of writing this so that it is not as primative, but looks like something? Do you know how this can be done?

Thanks,
Jonathan"
   

- Advertisement -