I have a field CODEAN.
with a ADO Sql is possible to check if exists a duplicates in CODAN and if is true fill DUP_CODEAN field with "SI".
sql to CHECK duplicate in field
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: sql to CHECK duplicate in field
Is DUP_CODEAN a field in the table, or is it a field that you want to return in a query (recordset)?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
-
- Administrator
- Posts: 78474
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: sql to CHECK duplicate in field
Use this SQL:
Change TableName to the name of your table.
Code: Select all
SQL = "UPDATE [TableName] SET DUP_CODEAN = 'SI' WHERE (SELECT Count(*) " & _
"FROM [TableName] AS T WHERE T.CODEAN=[TableName].CODEAN)>1"
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4355
- Joined: 26 Apr 2010, 17:36
Re: sql to CHECK duplicate in field
work!HansV wrote: ↑14 Sep 2020, 14:02Use this SQL:
Change TableName to the name of your table.Code: Select all
SQL = "UPDATE [TableName] SET DUP_CODEAN = 'SI' WHERE (SELECT Count(*) " & _ "FROM [TableName] AS T WHERE T.CODEAN=[TableName].CODEAN)>1"
tKS