Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
A little SQL Server brain-teaser question
Message
 
 
À
30/10/2013 15:33:59
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Web
Divers
Thread ID:
01586880
Message ID:
01586888
Vues:
40
>Remember the old game, "Name that Tune?"
>
>Where someone would say, "I can name that tune in 4 notes"...
>
>Well, let's play "Name that feature"...how many commands would it take to accomplish the following?
>
>Every time someone issues a SELECT statement that uses the READ COMMITTED isolation level (either directly with a txaction or indirectly, as it's the default isolation level)...I want the following...
>
>1) If the row is currently under a write lock (i.e. someone is updating it), I want the "last good committed version" ...and once that other person's update finishes and commits, if I read the row again (even in a txaction of my own) I'll get the updated value.
>
>2) If the row isn't currently under a write lock and there's no update transaction pending on the row, I want the row
>
>Normally in scenario 1, using READ COMMITTED to read a row (while an update is occurring by other user on the row) means the read will be locked out until the update txaction finishes. But I don't want to be locked out...in that case, I want the last good committed version.
>
>Granted, this isn't an every day occurrence.
>
>But how can I do it? How many lines of code :)
SELECT * from myTable WHERE ID = @ID WITH (READPAST)
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform