<?xml version="1.0" encoding="windows-1252"?>
<node id="1015018" title="Re: Perl Query Locks A MsSQL Database" created="2013-01-23 15:31:58" updated="2013-01-23 15:31:58">
<type id="11">
note</type>
<author id="757127">
tobyink</author>
<data>
<field name="doctext">
&lt;p&gt;Firstly, how are you connected? FreeTDS or ODBC? If you're connected through FreeTDS, it's pretty difficult to have two queries running concurrently on the same database handle. You need to finish your select before you run any updates. A workaround is to open two database handles on the same database.&lt;/p&gt;

&lt;p&gt;Secondly, by default MSSQL locks whole pages and often whole tables while one query is running, meaning a situation like yours is likely to cause deadlocks. You could experiment with adding some &lt;a href="http://msdn.microsoft.com/en-gb/library/ms187373.aspx"&gt;table hints&lt;/a&gt; to your select query; possibly &lt;c&gt;ROWLOCK&lt;/c&gt;, perhaps even &lt;c&gt;NOLOCK&lt;/c&gt; as a last resort.&lt;/p&gt;


&lt;div class="pmsig"&gt;&lt;div class="pmsig-757127"&gt;
&lt;small&gt;&lt;small&gt;&lt;tt&gt;package Cow { use Moo; has name =&gt; (is =&gt; 'lazy', default =&gt; sub { 'Mooington' }) } say Cow-&gt;new-&gt;name&lt;/tt&gt;&lt;/small&gt;&lt;/small&gt;
&lt;/div&gt;&lt;/div&gt;</field>
<field name="root_node">
1014976</field>
<field name="parent_node">
1014976</field>
</data>
</node>
