Can two separate cursors update the same SQL table when executed together?

5 pts.
Tags:
SQL Cursors
SQL Server 2005
SQL Server 2005 administration
SQL tables
I have three tables. Table One is a master table which contains rows which need to be updated with data from the other two tables (I'll call them Table Two and Table Three). I have created a cursor which updates existing rows in Table One with data from Table Two. This works fine, and following the successful execution of the cursor, Table One contains the new data. However, I have a second cursor, which updates the same columns in Table One as the first cursor does, (but never the same rows), and when this second cursor is executed, the data in Table One is updated with the data from Table Three. However, when querying Table One after the execution of the second cursor the data from Table Two is no longer present. Each cursor is executed in its own transaction, which is committed after the cursor has been closed and deallocated. This is my first attempt at using cursors, and I need to know whether what I'm doing is technically possible, and if so what may be causing the updates from the first cursor to be lost. Any help would be greatly appreciated! Thanks R.W.

Software/Hardware used:
SQL Server 2005

Answer Wiki

Thanks. We'll let you know when a new response is added.

Yes, two cursors can run against a single destination table at the same time. As far as SQL Server is concerned they are just transactions.

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following