<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="https://www.schweda.net/style_feed.css" ?>
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:atom="http://www.w3.org/2005/Atom"	
	xmlns:dc="http://purl.org/dc/elements/1.1/" > 
<channel>
    <title>schweda.net - Blog</title>
    <link>https://www.schweda.net/</link>
    <description>schweda.net - Blog - Blog-Beitraege</description>
    <language>de-at</language>
    <copyright>Copyright 2006-2026</copyright>
    <generator>schweda.net</generator>
    <managingEditor>heinz.schweda@schweda.net (Heinz Schweda)</managingEditor>
    <webMaster>heinz.schweda@schweda.net (Heinz Schweda)</webMaster>
    <category>Blog</category>
	<atom:link href="https://schweda.net/blog_rss.php?bid=407" rel="self" type="application/rss+xml" />
<item>
<title><![CDATA[Tabellen mit doppelten RecIDs ermitteln]]></title>
<description><![CDATA[
<p>Wenn man in Dynamics AX (4.0&nbsp;bzw. 2009) einmal in die Verlegenheit kommen sollte, pr&uuml;fen zu m&uuml;ssen, ob es Tabellen mit doppelten RecIDs gibt, kann folgendes SQL-Script dabei behilflich sein:
</p>

<div class="div_blog_sqlcode">use ax2009_standard_sp1<br />
<br />
set nocount on<br />
<br />
declare @tableName char(100)<br />
declare&nbsp;db_cursor CURSOR FOR&nbsp; <br />
&nbsp;select name from dbo.sysobjects<br />
&nbsp;where xtype = 'U'<br />
&nbsp;and name &lt;&gt; 'ROWSTAT'<br />
&nbsp;and name &lt;&gt; 'ROWSTATUS'<br />
&nbsp;and name &lt;&gt; 'SQLSYSTEMVARIABLES'<br />
&nbsp;and name &lt;&gt; 'SYSTEMSEQUENCES'&nbsp;-- SYSTEMSEQUENCES enth&auml;lt immer doppelte RecIDs<br />
&nbsp;order by name asc<br />
<br />
-- Tempor&auml;re Tabelle aufbauen<br />
IF OBJECT_ID(N'tempdb..#tmp_duplrecid', N'U') IS NOT NULL <br />
&nbsp;begin<br />
&nbsp;drop table #tmp_duplrecid<br />
&nbsp;end<br />
<br />
create table #tmp_duplrecid (tablename char(100), recordcounter bigint)&nbsp;&nbsp;&nbsp;<br />
<br />
OPEN db_cursor&nbsp;&nbsp; <br />
FETCH NEXT FROM db_cursor INTO @tableName&nbsp;&nbsp;<br />
<br />
WHILE @@FETCH_STATUS = 0&nbsp;&nbsp; <br />
&nbsp;BEGIN&nbsp;&nbsp; <br />
&nbsp;&nbsp;-- Tabellen mit doppelten RecIds ermitteln<br />
&nbsp;&nbsp;exec('insert into #tmp_duplrecid select ''' + @tableName + ''', COUNT(*)' + <br />
&nbsp;&nbsp;&nbsp; ' from ' + @tableName +<br />
&nbsp;&nbsp;&nbsp; ' group by RECID ' + <br />
&nbsp;&nbsp;&nbsp; ' having COUNT(*) &gt; 1')<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br />
&nbsp;&nbsp;FETCH NEXT FROM db_cursor INTO @tableName&nbsp;&nbsp; <br />
&nbsp;END&nbsp;&nbsp;<br />
<br />
CLOSE db_cursor&nbsp;&nbsp; <br />
DEALLOCATE db_cursor<br />
<br />
set nocount off<br />
<br />
-- Tabellen mit doppelten RecIDs<br />
select 'Tabelle enth&auml;lt doppelte RecIDs: ' + tablename<br />
from #tmp_duplrecid
</div>

<p><br />
&nbsp;
</p>]]></description>
<category>Microsoft Dynamics AX (Axapta)</category>
<pubDate>Wed, 04 May 2011 20:06:00 +0200</pubDate>
<link>https://www.schweda.net/blog_ax.php?bid=407</link>
<comments>https://www.schweda.net/blog_ax.php?bid=407</comments>
<guid isPermaLink="true">https://www.schweda.net/blog_ax.php?bid=407</guid>
<author>heinz.schweda@schweda.net (Heinz Schweda)</author>
<wfw:commentRss>https://www.schweda.net/blog_ax.php?bid=407</wfw:commentRss>
</item>
</channel>
</rss>	
