Find duplicates with select statement

Microsoft Axapta Development, Management, Functional and Technical Support Discussions.

Find duplicates with select statement

Post by usenet » Fri Jul 03, 2009 6:25 am

I want to determine if a table has several fields with the same values. The
SQL syntax on the SQL-Server would be like this:

SELECT field1, field2, field3 FROM WK_MyTable
group by field1, field2, field3
having count(*) > 1

Is there any posibility to get this information in x++ with an select
statemen?

Thanks
Iven
More available at Technology Forums
usenet
 
Posts: 80094
Joined: Wed Jun 24, 2009 8:14 am

RE: Find duplicates with select statement

Post by usenet » Fri Jul 03, 2009 9:16 am

Hi Iven,

Maybe something like this?
-----------------------------------------------------
WK_MyTable wk_MyTable;
WK_MyTable wk_MyTableMatch;
;

SELECT field1, field2, field3 FROM wk_MyTable
group by field1, field2, field3
exists join wk_MyTableMatch
where wk_MyTableMatch.field1 == wk_MyTabld.field1
&& wk_MyTableMatch.field2 == wk_MyTabld.field2
&& wk_MyTableMatch.field3 == wk_MyTabld.field3
&& wk_MyTableMatch.RecID != wk_MyTable.RecID;

--
Best regards,
Sasha Nazarov


"Iven" wrote:

> I want to determine if a table has several fields with the same values. The
> SQL syntax on the SQL-Server would be like this:
>
> SELECT field1, field2, field3 FROM WK_MyTable
> group by field1, field2, field3
> having count(*) > 1
>
> Is there any posibility to get this information in x++ with an select
> statemen?
>
> Thanks
> Iven
More available at Technology Forums
usenet
 
Posts: 80094
Joined: Wed Jun 24, 2009 8:14 am

RE: Find duplicates with select statement

Post by usenet » Fri Jul 03, 2009 2:17 pm

Yes this should solve my problem.

Thanks!

"Sasha Nazarov [MSFT]" wrote:

> Hi Iven,
>
> Maybe something like this?
> -----------------------------------------------------
> WK_MyTable wk_MyTable;
> WK_MyTable wk_MyTableMatch;
> ;
>
> SELECT field1, field2, field3 FROM wk_MyTable
> group by field1, field2, field3
> exists join wk_MyTableMatch
> where wk_MyTableMatch.field1 == wk_MyTabld.field1
> && wk_MyTableMatch.field2 == wk_MyTabld.field2
> && wk_MyTableMatch.field3 == wk_MyTabld.field3
> && wk_MyTableMatch.RecID != wk_MyTable.RecID;
>
> --
> Best regards,
> Sasha Nazarov
>
>
> "Iven" wrote:
>[color=green]
> > I want to determine if a table has several fields with the same values. The
> > SQL syntax on the SQL-Server would be like this:
> >
> > SELECT field1, field2, field3 FROM WK_MyTable
> > group by field1, field2, field3
> > having count(*) > 1
> >
> > Is there any posibility to get this information in x++ with an select
> > statemen?
> >
> > Thanks
> > Iven
[/color]
More available at Technology Forums
usenet
 
Posts: 80094
Joined: Wed Jun 24, 2009 8:14 am


Return to Axapta



Who is online

Users browsing this forum: No registered users and 2 guests