473,795 Members | 3,122 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to change Primary Key value in existing database?

12 New Member
Hello everybody!
I’ve inherited a moderate size Employee database.
Main Employees table has a SSN as a primary key, but it is a “Text” data type.
I’m now told to delete social security numbers due to security reasons, change primary key to preferably autonumber or other unique value, but still keep last 4 digits as a new field.

tblMain structure
SSN;Text; primary key
LastName; Text
FirstName;Text

This table is in one to many relationship to 10 other tables.
Recently I selected “Cascade Update Related Fields” in order to update some incorrect numbers.

Here are my thoughts:
Using Right([SSN],4) I will create a new field in tblMain to track last 4 digits.
This field unfortunately has to be a “Text” in order to run append query.
As for changing SSN field to autonumber- no solution yet.
I could manually update SSN to unique text using first 3-4 letters of the name, but how to make users to apply same technique when entering new employee?

Any help is greatly appreciated!

Victor
Mar 23 '07 #1
2 10880
VictorS
12 New Member
Correcting myself:
I cannot use autonuber in tblMain- it will allow duplicate entry.
Here is what I did so far:
Used Update quert to create field "Last4SSN" using expression
Right([SSN],4)
Used Update query to create field "NewId";Tex t data using expression
Left([LastName],1) & Mid([FirstName],1,1) & Right([Last4SSN],4)
"NewId" field appears to be unique.
Next step- manually update SSN field to new values of "NewId"
I guess I have keep fields name as is (SSN) in order to make everything work.
Mar 23 '07 #2
Rabbit
12,516 Recognized Expert Moderator MVP
Is this a make table query? I assume it is.

The problem with your expression is that with enough people you're eventually going to have 2 people with the same ID.

What you can do is use a multi column primary key. After the table is made, go into table design view and set the last name, first name, and last 4 SSN as the primary keys.
Mar 23 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
3589
by: John Simmons | last post by:
How is it that even though I have the column "username" in my database set as a Primary key, using my PHP script to add new users to the database works without any errors even when signing up using an existing username. I have a database full of the same usernames!
9
9587
by: Bob C. | last post by:
I want to create a 1-many relationship. Parent table has a primary key, child table has no primary key. The child table does have an index with all four fields of the parent's PK. How can I do this? Thanks, Bob C.
2
2912
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...
4
1655
by: Megan | last post by:
Hi- I need some help/ advise on how to code unique numbers for the primary keys of my 2 tables. I inherited a database that covers information about Hearings and Rulings. Information about the Hearings and Rulings were stored in 1 generic table called Case. I split it into 2 tables, Hearings and Rulings. The problem is that the primary key, CaseID, is an autonumber. I don't want the Hearings and Rulings to have the same number.
6
3085
by: GaryDave | last post by:
My school registration database has not been quite right after a recent compact and repair (done while I was away). Though most of the many forms and subforms are working normally, one form in particular will no longer allow new entries into the subform - the recordset of the underlying query is no longer updatable. The subform in question enters the identity and other vital info for children whose parent's ID provides the FK, linking...
4
7032
by: Michael Hannon | last post by:
Greetings. We're running Postgres 7.3 on an Intel linux box (Redhat Enterprise server, version 3.0). We find ourselves in an awkward position: we have a database of attributes relating to students that uses as its primary key the ID number of the student. This is awkward for the following reasons. Our university used to use social-security numbers for student ID's. They stopped doing that a few years ago, but didn't force the change...
9
3911
by: sonal | last post by:
Hi all, I hv started with python just recently... and have been assigned to make an utility which would be used for data validations... In short we take up various comma separated data files for eg: area.txt, school.txt, students.txt.... and so on (ok?!?) now, 1. area code used in the school.txt must be defined in the area.txt (Primary key in area => area_code defined in area.txt & Foreign key on school => area_code defined in...
3
1471
by: lrg | last post by:
i created a table with 2 columns as primary key and inserted 100 records. now i want to include one more column as primary key. Will this change be reflected in the existing records or i've to reinsert these records so as to make the change in primary key reflect on these 100 records? thanks in advance, lrg.
1
11910
by: Frank Swarbrick | last post by:
We're trying to take advantage of the new ROW CHANGE TIMESTAMP option. Here is a simple table: CREATE TABLE "ACCTASGN"."NUMBER_STATUS" ( "STATUS_CODE" CHAR(1) NOT NULL , "STATUS_DESCRIPTION" VARCHAR(40) NOT NULL , "LAST_UPDATE" TIMESTAMP NOT NULL GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP
0
9672
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
9519
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
10439
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...
0
9043
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5437
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...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
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.