<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Forum — Error with Del7 - is there another way of batch deleting records?]]></title>
		<link>https://forums.nbn.org.uk/viewtopic.php?id=8087</link>
		<atom:link href="https://forums.nbn.org.uk/extern.php?action=feed&amp;tid=8087&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Error with Del7 - is there another way of batch deleting records?.]]></description>
		<lastBuildDate>Wed, 01 Jul 2026 10:22:04 +0000</lastBuildDate>
		<generator>PunBB 1.4.6</generator>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31515#p31515</link>
			<description><![CDATA[<p>AMAZING!!! Someone buy that man a pint :)</p>]]></description>
			<author><![CDATA[null@example.com (paul.stevens)]]></author>
			<pubDate>Wed, 01 Jul 2026 10:22:04 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31515#p31515</guid>
		</item>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31514#p31514</link>
			<description><![CDATA[<p>Here is a new version of the XML that includes deleting any related Taxon_Private_Data rows. Hopefully this will fix the problem.</p><p>&lt;?xml version=&quot;1.0&quot; ?&gt;<br />&lt;!-- Not System Supplied&nbsp; &nbsp;</p><p>&nbsp; &nbsp; &nbsp;XML Batch Update by Mike Weideli of Littlefield Consultancy<br />&nbsp; &nbsp; &nbsp;<a href="http://www.lfield.co.uk">http://www.lfield.co.uk</a><br />&nbsp; &nbsp; &nbsp;Version 3 - June 2026 (amended by Andy Foy) --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&lt;batchupdate menupath=&quot;Delete&quot; title=&quot;Del7 Delete Taxon Occurrences based on csv file.&quot;</p><p>description=&quot;This batch update deletes taxon occurrences and all the related structure.<br />It also deletes the Samples and Survey Events where the deletion of the Taxon Occurrence results in these having no data.<br />Restricted to 3000 records at a time.<br />See <a href="https://forums.nbn.org.uk/viewtopic.php?id=7866">https://forums.nbn.org.uk/viewtopic.php?id=7866</a> for note of why it might not work.<br />Script: JNCCDel7Record.xml&quot; &gt;</p><p>&lt;CSVTables&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVTable name=&quot;#CSV1&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVFile description=&quot;Taxon Occurrence File&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVColumn name = &quot;Taxon_Occurrence_Key&quot; datatype=&quot;Char&quot; size=&quot;16&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/CSVTable&gt;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&lt;/CSVTables&gt;</p><p>&lt;SQL&gt;<br />&nbsp; &nbsp;<br />CREATE TABLE #LCDelete ( Survey_Event_key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Sample_Key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS,<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; Taxon_Occurrence_key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS )</p><p>&lt;Where keytype=&quot;Default&quot;&gt;</p><p>&nbsp; &nbsp;INSERT INTO #LCDelete (Taxon_Occurrence_Key)<br />&nbsp; &nbsp;SELECT DISTINCT Taxon_Occurrence_Key from #CSV1 </p><p>&nbsp; &nbsp;UPDATE #LCDELETE SET SAMPLE_KEY = TOCC.Sample_Key<br />&nbsp; &nbsp;FROM Taxon_Occurrence TOCC<br />&nbsp; &nbsp;INNER JOIN #LCDELETE ON TOCC.Taxon_Occurrence_Key = #LCDELETE.Taxon_Occurrence_Key</p><p>&nbsp; &nbsp;UPDATE #LCDELETE SET SURVEY_EVENT_Key = S.Survey_Event_key<br />&nbsp; &nbsp;FROM Sample S<br />&nbsp; &nbsp;INNER JOIN #LCDELETE ON S.Sample_Key = #LCDELETE.Sample_Key<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TDET<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_DETERMINATION TDET INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TDET.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TSC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_OCCURRENCE_SOURCES&nbsp; TSC INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TSC.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN&nbsp; &nbsp;<br />&nbsp; &nbsp;DELETE FROM TDAT<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_OCCURRENCE_DATA&nbsp; TDAT INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TDAT.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN <br />&nbsp; &nbsp;DELETE FROM TREL<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_OCCURRENCE_RELATION&nbsp; TREL INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TREL.TAXON_OCCURRENCE_KEY_1<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TREL2<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_OCCURRENCE_RELATION&nbsp; TREL2 INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TREL2.TAXON_OCCURRENCE_KEY_2<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SP<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SPECIMEN SP INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = SP.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TPD<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;Taxon_Private_Data TPD INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TPD.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@Rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TOCC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;TAXON_OCCURRENCE TOCC INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TOCC.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@Rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;DELETE FROM #LCDELETE<br />&nbsp; &nbsp;WHERE EXISTS(SELECT * FROM TAXON_OCCURRENCE TOCC WHERE TOCC.sample_key = #LCDELETE.SAMPLE_KEY)</p><p>&nbsp; &nbsp;DELETE FROM #LCDELETE<br />&nbsp; &nbsp;WHERE EXISTS(SELECT * FROM BIOTOPE_OCCURRENCE BOCC WHERE BOCC.sample_key = #LCDELETE.SAMPLE_KEY)</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SSC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_SOURCES SSC INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SSC.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SDAT<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_DATA SDAT INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SDAT.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SAD<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_Admin_Areas SAD INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SAD.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREL1<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_RELATION SREL1 INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREL1.SAMPLE_KEY_1<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREL2<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_RELATION SREL2 INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREL2.SAMPLE_KEY_2<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE_RECORDER SREC INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREC.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM S<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SAMPLE S INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = S.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;DELETE FROM #LCDELETE WHERE<br />&nbsp; &nbsp;EXISTS (SELECT * FROM SAMPLE S WHERE S.Survey_Event_key = #LCDELETE.Survey_Event_key)</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SSC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SURVEY_EVENT_SOURCES SSC INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SSC.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SEREC<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SURVEY_EVENT_RECORDER SEREC INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SEREC.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SEO<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SURVEY_EVENT_OWNER SEO INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SEO.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1<br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SE<br />&nbsp; &nbsp;FROM<br />&nbsp; &nbsp;SURVEY_EVENT SE INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SE.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;DROP TABLE #LCDELETE</p><p>&lt;/Where&gt;</p><p>&lt;/SQL&gt;</p><p>&lt;/batchupdate&gt;</p>]]></description>
			<author><![CDATA[null@example.com (AndyFoy)]]></author>
			<pubDate>Tue, 30 Jun 2026 14:13:30 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31514#p31514</guid>
		</item>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31513#p31513</link>
			<description><![CDATA[<p>Thanks Andy! Here it is</p><p>&lt;?xml version=&quot;1.0&quot; ?&gt;<br />&lt;!-- Not SYstem Supplied&nbsp; &nbsp; <br />&nbsp; <br />&nbsp; &nbsp; &nbsp;XML Batch Update by Mike Weideli of Littlefield Consultancy<br />&nbsp; &nbsp; &nbsp;<a href="http://www.lfield.co.uk">http://www.lfield.co.uk</a><br />&nbsp; &nbsp; &nbsp;Version 2 - October 2010 --&gt;<br />&nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; <br />&lt;batchupdate menupath=&quot;Delete&quot; title=&quot;Del7 Delete Taxon Occurences based on csv file.&quot; </p><p>description=&quot;This batch update deletes taxon occurrences and all the related structure. <br />It also deletes the Samples and Survey Events where the deletion of the Taxon Occurrence results in these having no data. <br />Restricted to 3000 records at a time.<br />See <a href="https://forums.nbn.org.uk/viewtopic.php?id=7866">https://forums.nbn.org.uk/viewtopic.php?id=7866</a> for note of why it might not work.<br />Script: JNCCDel7Record.xml&quot; &gt;</p><br /><br /><br /><p>&lt;CSVTables&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVTable name=&quot;#CSV1&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVFile description=&quot;Taxon Occurrence File&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;CSVColumn name = &quot;Taxon_Occurrence_Key&quot; datatype=&quot;Char&quot; size=&quot;16&quot; /&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/CSVTable&gt;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />&lt;/CSVTables&gt;</p><p>&lt;SQL&gt;<br />&nbsp; &nbsp;<br />CREATE TABLE #LCDelete (&nbsp; &nbsp; &nbsp; &nbsp; Survey_Event_key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS, <br />&nbsp; &nbsp; &nbsp; &nbsp; Sample_Key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS,<br />&nbsp; &nbsp; &nbsp; &nbsp; Taxon_Occurrence_key char(16) COLLATE SQL_Latin1_General_CP1_CI_AS<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; )<br />&lt;Where keytype=&quot;Default&quot;&gt;<br />&nbsp; &nbsp;</p><p>&nbsp; &nbsp;INSERT INTO #LCDelete (Taxon_Occurrence_Key) <br />&nbsp; &nbsp;SELECT DISTINCT&nbsp; Taxon_Occurrence_Key from #CSV1&nbsp; </p><p>&nbsp; &nbsp;UPDATE #LCDELETE SET SAMPLE_KEY = TOCC.Sample_Key<br />&nbsp; &nbsp;FROM Taxon_Occurrence TOCC<br />&nbsp; &nbsp;INNER JOIN #LCDELETE ON TOCC.Taxon_Occurrence_Key = #LCDELETE.Taxon_Occurrence_Key<br />&nbsp; &nbsp;</p><p>&nbsp; &nbsp;UPDATE #LCDELETE SET SURVEY_EVENT_Key = S.Survey_Event_key <br />&nbsp; &nbsp;FROM Sample S <br />&nbsp; &nbsp;INNER JOIN #LCDELETE ON&nbsp; S.Sample_Key&nbsp; = #LCDELETE.Sample_Key </p><br /><p>&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TDET<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_DETERMINATION TDET INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TDET.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;<br />&nbsp; &nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; <br />&nbsp; &nbsp;END <br />&nbsp; <br />&nbsp; &nbsp;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TSC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_OCCURRENCE_SOURCES&nbsp; TSC INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TSC.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; <br />&nbsp; &nbsp;END <br />&nbsp; </p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN&nbsp; &nbsp;<br />&nbsp; &nbsp;DELETE FROM TDAT<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_OCCURRENCE_DATA&nbsp; TDAT INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TDAT.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /> <br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN&nbsp; <br />&nbsp; &nbsp;DELETE FROM TREL<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_OCCURRENCE_RELATION&nbsp; TREL INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TREL.TAXON_OCCURRENCE_KEY_1<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TREL2<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_OCCURRENCE_RELATION&nbsp; TREL2 INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TREL2.TAXON_OCCURRENCE_KEY_2<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SP<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SPECIMEN SP INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = SP.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM TOCC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;TAXON_OCCURRENCE TOCC INNER JOIN #LCDELETE #LCD ON #LCD.TAXON_OCCURRENCE_KEY = TOCC.TAXON_OCCURRENCE_KEY<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;IF @@Rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;DELETE FROM #LCDELETE <br />&nbsp; &nbsp;WHERE EXISTS(SELECT * FROM TAXON_OCCURRENCE TOCC WHERE TOCC.sample_key = #LCDELETE.SAMPLE_KEY)<br />&nbsp; &nbsp;</p><p>&nbsp; &nbsp;DELETE FROM #LCDELETE <br />&nbsp; &nbsp;WHERE EXISTS(SELECT * FROM BIOTOPE_OCCURRENCE BOCC WHERE BOCC.sample_key = #LCDELETE.SAMPLE_KEY)<br />&nbsp; &nbsp;</p> <br /><p>&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SSC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_SOURCES SSC INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SSC.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SDAT<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_DATA SDAT INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SDAT.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SAD<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_Admin_Areas SAD INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SAD.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREL1<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_RELATION SREL1 INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREL1.SAMPLE_KEY_1<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREL2<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_RELATION SREL2 INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREL2.SAMPLE_KEY_2<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SREC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE_RECORDER SREC INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = SREC.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM S<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SAMPLE S INNER JOIN #LCDELETE #LCD ON #LCD.SAMPLE_KEY = S.SAMPLE_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;DELETE FROM #LCDELETE WHERE <br />&nbsp; &nbsp;EXISTS (SELECT * FROM SAMPLE S WHERE S.Survey_Event_key = #LCDELETE.Survey_Event_key)</p><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SSC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SURVEY_EVENT_SOURCES SSC INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SSC.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><p>&nbsp; <br />&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SEREC<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SURVEY_EVENT_RECORDER&nbsp; SEREC INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SEREC.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END<br />&nbsp; &nbsp;<br />&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SEO<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SURVEY_EVENT_OWNER&nbsp; SEO INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SEO.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END</p><br /><p>&nbsp; &nbsp;set rowcount&nbsp; 3000<br />&nbsp; &nbsp;WHILE 1 =1 <br />&nbsp; &nbsp;BEGIN<br />&nbsp; &nbsp;DELETE FROM SE<br />&nbsp; &nbsp;FROM <br />&nbsp; &nbsp;SURVEY_EVENT&nbsp; SE INNER JOIN #LCDELETE #LCD ON #LCD.SURVEY_EVENT_KEY = SE.SURVEY_EVENT_KEY<br />&nbsp; &nbsp;IF @@rowcount &amp;#60; 3000 BREAK<br />&nbsp; &nbsp;END<br />&nbsp; &nbsp;</p><br /><p>&nbsp; &nbsp;DROP TABLE #LCDELETE</p><p>&lt;/Where&gt;</p><br /><br /><p>&nbsp; &nbsp;</p><br /><p>&lt;/SQL&gt;</p><br /><br /><p>&lt;/batchupdate&gt;</p>]]></description>
			<author><![CDATA[null@example.com (paul.stevens)]]></author>
			<pubDate>Tue, 30 Jun 2026 09:47:48 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31513#p31513</guid>
		</item>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31512#p31512</link>
			<description><![CDATA[<p>I will if someone can share the xml file with me.</p>]]></description>
			<author><![CDATA[null@example.com (AndyFoy)]]></author>
			<pubDate>Fri, 26 Jun 2026 07:59:48 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31512#p31512</guid>
		</item>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31511#p31511</link>
			<description><![CDATA[<p>Andy - could you post a solution/comments to this as I have been fighting with the same problem?</p><p>Bob Marsh</p>]]></description>
			<author><![CDATA[null@example.com (atheta01)]]></author>
			<pubDate>Fri, 26 Jun 2026 07:53:40 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31511#p31511</guid>
		</item>
		<item>
			<title><![CDATA[Re: Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31510#p31510</link>
			<description><![CDATA[<p>I don&#039;t have a Del7 batch update to check but my guess would be that it doesn&#039;t include deleting related Taxon_Private_Data records, as this is a relatively new table, and hence fails when trying to delete Taxon_Occurrence records. Can you post the xml code?</p>]]></description>
			<author><![CDATA[null@example.com (AndyFoy)]]></author>
			<pubDate>Thu, 25 Jun 2026 13:15:27 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31510#p31510</guid>
		</item>
		<item>
			<title><![CDATA[Error with Del7 - is there another way of batch deleting records?]]></title>
			<link>https://forums.nbn.org.uk/viewtopic.php?pid=31509#p31509</link>
			<description><![CDATA[<p>Hi. I understand from looking through this forum that this has been an issue before! I&#039;m trying to delete some duplicate records. I have followed these steps to create a list of records to delete: </p><p>Create a csv file containing the records you want to delete.</p><p>Change the Obs Key field to “Taxon_Occurrence_Key” and cut and paste this so that it’s the first column in the sheet </p><p>Add a field called “Determination_Type” in which all the rows must have the value “Delete” </p><p>Add a column called “Verifiers_Comments” and another one called “Scientific_name”, both of which can be blank </p><p>Delete all the other fields in the csv and close it </p><p>however, when I try to use this as the input to Del7, I get the following error message: </p><p>There is an error in the SQL code. The error message is: &quot;The DELETE statement conflicted with the REFERENCE constraint &quot;FK_TAXON_PRIVATE_DATA_OCCURRENCE&quot;. The conflict occurred in database &quot;NBNData&quot;, table &quot;dbo.Taxon_Private_Data&quot;, column &quot;Taxon_Occurrence_Key&quot;. </p><p>Can anyone help? </p><p>Thanks very much, Jo</p>]]></description>
			<author><![CDATA[null@example.com (paul.stevens)]]></author>
			<pubDate>Wed, 24 Jun 2026 12:35:12 +0000</pubDate>
			<guid>https://forums.nbn.org.uk/viewtopic.php?pid=31509#p31509</guid>
		</item>
	</channel>
</rss>
