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 2008 Forums
 Transact-SQL (2008)
 Interesting Sql protocol issue around SP results

Author  Topic 

blakmk
Starting Member

45 Posts

Posted - 2012-10-08 : 10:42:38
I have a requirement to return a batch of records and then mark the batch complete. I was thinking to acheive this with a select and the update. Something like:

UPDATE dbo.Table
SET Retrieved = 'Y'
OUTPUT inserted.x, inserted.y, inserted.z;
The question I have, is what happens if the procedure executes, returns the select but the connection breaks before the batch is re received Does the batch still get updated?

Otherwise can anyone think of a better way to acheive this with stored procs?

www.DataTao.co.uk

chadmat
The Chadinator

1974 Posts

Posted - 2012-10-08 : 15:50:27
You should just do an SP, return the records, then update. If it is all within a transaction it is all or nothing, everything commits, or everything rolls back.

-Chad
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-08 : 19:58:44
i think you should be doing select followed by an update of retrieved field as 'Y' both wrapped within a transaction

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

Go to Top of Page
   

- Advertisement -