Is there an easy way in SQLServer touse data as READ_ONCE? What I mean is, can I set it to delete a row after it has selected it?
+2
A:
You could do this easily if the data is accessed through a stored procedure. You can select the data into a temp table, delete the data and return the temp. All wrapped in a transaction of course.
Paul Sasik
2009-12-09 16:54:24
+5
A:
Off the top of my head, the only way I can think of would be to restrict all logins to prohiibit any Select access, and only allow access through a stored procedure "FetchMyWhateverData" and then delete the rows as second SQL statement inside the stored proc.
CreateProcedure FetchMyWhateverData
@MyEntityId Integer,
As
Set NoCount On
Select * From TableName
Where Id = @MyEntityId
Delete TableName
Where Id = @MyEntityId
Return 0
-- and adding in the other appropriate infrastructure code of course.
Charles Bretana
2009-12-09 16:55:08
Unfortunately, constraints we have been given do not allow us to create procs. This was a solution we had thought of. I apologize for not being more explicit in question.
Adam Lerman
2009-12-09 17:52:12
+2
A:
If you read it with DELETE ... OUTPUT ...
. This is how queues work.
Remus Rusanu
2009-12-09 17:30:06