how to unloch table in sql
-
-
hi to all i lock a table in sql with belwo query
begin tran
select * from BML.LoanApplication with(TABLOCKX)now i want to unlock this table but i cant . i can read from this table by nolock but i want to unlock this table any help can be usefule
-
hi to all i lock a table in sql with belwo query
begin tran
select * from BML.LoanApplication with(TABLOCKX)now i want to unlock this table but i cant . i can read from this table by nolock but i want to unlock this table any help can be usefule
commit tran
-
-
mehdi.sabet wrote:
ok but this is when that you use COMMIT end of my related code.
but i dont use COMMIT tran in my code.First, it's a lousy example; there's no way that the server can "guess" whether it should be rolled back or comitted automatically. Second, there is nothing to commit or rollback, since a
SELECT
statement doesn't change the data. Don't use a transaction when selecting. Also, set[XACT ABORT](http://msdn.microsoft.com/en-us/library/ms188792.aspx)[[^](http://msdn.microsoft.com/en-us/library/ms188792.aspx "New Window")]
to ON. Also, don't lock an entire table, unless really, really required.mehdi.sabet wrote:
and if use this code you can see that this table is lock:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
mehdi.sabet wrote:
ok but this is when that you use COMMIT end of my related code.
but i dont use COMMIT tran in my code.First, it's a lousy example; there's no way that the server can "guess" whether it should be rolled back or comitted automatically. Second, there is nothing to commit or rollback, since a
SELECT
statement doesn't change the data. Don't use a transaction when selecting. Also, set[XACT ABORT](http://msdn.microsoft.com/en-us/library/ms188792.aspx)[[^](http://msdn.microsoft.com/en-us/library/ms188792.aspx "New Window")]
to ON. Also, don't lock an entire table, unless really, really required.mehdi.sabet wrote:
and if use this code you can see that this table is lock:
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]