473,397 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Finding and Correcting Missing Column data in a single table

19
Good afternoon folks, a quick question for all you SQL gurus out there. I'm cleaning up a table from another person at my company and am running into a small problem.

Assume:

Table: T1
-----------------
Field1 - String, not unique
Field2 - String, not unique

No PK is defined.

I have 58,000 some odd entries in T1, there are other columns but I'm only concerned with these two. There is no unique identifier in this table (it's being migrated into SQL and that hasn't been decided on yet).

Some of the records have initials input into Field2 (such as BA, DO, ZK, etc..). There are multiple entries for the same value in Field1. When I need to do is find all the records where Field1 is the same but Field2 differs, then update Field2 so that all the Field1 records have the same Field2 records. I.e. this:

Existing data:
--------------------
12345 DK
12345 DK
12345 NULL
12345 PD

Data after fix:
-------------------
12345 DK
12345 DK
12345 DK
12345 DK

Can someone point me in the right direction to resolve this? The engine is SQL Server 2000.
Nov 14 '07 #1
1 1344
iburyak
1,017 Expert 512MB
To find such records do following:

Expand|Select|Wrap|Line Numbers
  1. Select Field1, count(distinct isnull(Field2,’’))
  2. From table
  3. Group by Field1
  4. Having count(distinct isnull(Field2,’’)) > 1
How do you determine what to update Field2 is it a minimum not null value?
Nov 14 '07 #2

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

Similar topics

4
by: Aaron W. West | last post by:
Timings... sometimes there are almost too many ways to do the same thing. The only significant findings I see from all the below timings is: 1) Integer math is generally fastest, naturally....
20
by: Steve Jorgensen | last post by:
Hi all, I've just finished almost all of what has turned out to be a real bear of a project. It has to import data from a monthly spreadsheet export from another program, and convert that into...
6
by: Maxi | last post by:
I have 100 tabes in an Access database, every table has 1 filed with 100 names (records), no primary key assigned. I would like to find duplicates. Here is the criteria: The computer should...
3
by: DavidB | last post by:
New to .net....sorry if this seems repetitive I have a dataset ordered by date (SQLDataAdapter SelectCommand uses Order By) and want to find a record by a UniqueID(Identity Column). Then I want...
2
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
6
by: Hemant Shah | last post by:
Folks, Today, I was exporting a table in one database and then importing it in another database. The table in destination database was missing one column (my mistake while creating the table),...
0
by: sachjn | last post by:
Hi, I have three tables with columns as: Person_sys1 Id(pk) name telephoneNum userid ----- -------- ---------------------- --------- Person_sys2 Id(pk) name ...
3
by: cheguashwini | last post by:
Hi I have a problem. I have two tables...table1 and table2. table1 has the column latitude and sno(serial number) and table2 has the column lat and sno(serial number) . i have to find the...
5
by: maury | last post by:
Hello, I have a DB table with data filled from a weather sensor probe, I have one row every 10 minutes and the data fields is not in DateTime format but in string format: yyyyMMddHHmm So for...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
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...
0
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,...

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.