A co-worker informed me the other day that using NOLOCK in a cfquery is pointless if you do not include the query inside a cftransaction. He claims that SQL Server will only recognize NOLOCK inside a transaction and thus not having the query within a cftransaction makes the NOLOCK redundant.
Can someone confirm is this is true or not, because in all the CF shops in which I’ve worked , NOLOCK is used generously, and it is rarely ever inside a cftransaction. Am I supposed to think that all those queries in all those shops are not actually respecting the NOLOCK?
Your co-worker in incorrect,
NOLOCKis not redundant outside the contextcftransaction.If you are using the default setting in SQL Server, every query you execute is wrapped within a transaction whether you have explicitly typed it out or not. This is called “autocommit mode“.