473,666 Members | 2,237 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

create a primary key in an existing table that currently does not have one.


I encountered problem when i tried to create a primary key in an
existing table which does not have one yet. There are too many records
in it and it's hard to find out which one is 'duplicated'.
I'm not sure whether, if there is any duplicate records in the table.
How can i solve this problem?

Thanks
leah

Nov 7 '06 #1
3 3467
1)
create the primary key and let access tell you if there a conflict

2)
create a query that counts the number of times each value of the field
that will become the primary key exists, ie
SELECT tblItem.itemId, Count(tblItem.i temId) AS CountOfitemId
FROM tblItem
GROUP BY tblItem.itemId
ORDER BY Count(tblItem.i temId) DESC;
leah wrote:
I encountered problem when i tried to create a primary key in an
existing table which does not have one yet. There are too many records
in it and it's hard to find out which one is 'duplicated'.
I'm not sure whether, if there is any duplicate records in the table.
How can i solve this problem?

Thanks
leah
Nov 7 '06 #2
See:
Finding Duplicates in an imported DBF
at:
http://allenbrowne.com/xbase-04.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"leah" <le******@yahoo .comwrote in message
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
>
I encountered problem when i tried to create a primary key in an
existing table which does not have one yet. There are too many records
in it and it's hard to find out which one is 'duplicated'.
I'm not sure whether, if there is any duplicate records in the table.
How can i solve this problem?

Nov 7 '06 #3

Thanks for the replies.
It's working.
Thanks for the URL too.
Thanks again.

leah

Nov 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2907
by: Andrew Grandison | last post by:
We are converting a legacy visual foxpro system to use a SQL back-end. A number of (existing DBF) tables currently have a zero-filled primary key eg. '000255' which is just an auto-incrementing key - but always stored as a char field with leading zeros. For backward compatibility we are considering retaining this primary key and using an identity field to auto-generate the next value, then convert the new identity value into the new...
2
13919
by: Alicia | last post by:
Does anyone know why I am getting a "Syntax error in Create Table statement". I am using Microsoft Access SQL View to enter it. Any other problems I may run into? CREATE TABLE weeks ( weekstart datetime not null primary key, weekend datetime not null )
7
8851
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I want my users to be able to select a report, click on a command button on a form, which will then automatically create the report as a pdf file and save it to the user's machine. I am using Adobe Acrobat (5.0 I think) and have Adobe Distiller as a
1
2619
by: rdemyan via AccessMonster.com | last post by:
My application has a table that contains information on buildings. The building data comes from another database and is imported from a spreadsheet into my application. Originally, I thought that when a building data update is available, I would simply delete the existing data and import the new data into the table. However, now it seems that there may be a requirement to keep the historical data. Of course there is mountains of code...
27
3774
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
4
12428
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
4
2356
by: Queenie | last post by:
I have an existing contact information database which consists of a number of tables, the main table has a primary key which is currently set to NUMBER. There is a relationship between it and 2 other tables via that key (ContactID). I would now like to change the primary key (ContactID) to AUTONUMBER, so that any new records added, have a number assigned automatically. I also need any newly created primary key number to be used in the...
1
12761
by: dave.j.thornton | last post by:
I'm attempting to create a new table, and populate it using the fields from two existing tables. The code is printed below. I get the error: "Run-time error '-2147217900 (80040e14)': Syntax error in CREATE TABLE statement." For what it's worth, when tested independently, the "SELECT " part of my CREATE TABLE statement works properly. Sub test() Dim cmd As ADODB.Command Set cmd = New ADODB.Command
4
2847
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range (simply a "from" date and a "to" date)? Additionally, I need to delivery a specific quantity of product when the customer's inventory is within about parameter levels. EXAMPLE: "During the Date Range January 1, 2010 through April 30, 2010 when...
0
8440
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8355
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8866
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8550
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8638
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4193
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4365
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1769
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.