Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Issue explicit lock for testing
Message
De
11/11/2008 11:03:01
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01347107
Message ID:
01361095
Vues:
77
>>>>I am working on exception handling code in our .Net app.
>>>>
>>>>In VFP I could open another session of VFP and issue a Record or Table lock to test exception handling.
>>>>Is there any way to do something similar in SQL Server using SMSS? Just looking for an easy way to get an update or insert to fail.
>>>>All of our CRUD operations use SPs.
>>>>
>>>>Thanks
>>>
>>>If you open the table in SSMS, make a change to the record, but not move pointer, would it simulate a lock ?
>>
>>Good idea, but did not work. Sergey's idea was the trick.
>
>How exactly did you implement it?
-- Will hold a lock on a record until COMMIT is issued. Exec 1 line at a time in SMSS


BEGIN TRANSACTION

SELECT SomeColumn FROM dbo.MyTable WITH (TABLOCKX) WHERE SomeCriteria

(Now run application code against locked record)

COMMIT  -- Releases lock
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform