I have a table that has become corrupt and I need to merge the records back into one record. I have multiple records that should be recombined and I have hit a brick wall on this.
In my table the data looks like this
part_id Unique c_date m_date Qty ht_num
1 SWA123 6/1/2009 null null 28683
2 SWA123 null null 115 null
3 SWA123 null 6/2/2009 null 28683
This data used to be one single record. I have thousands of these that need merged again. Unfortunately, I only have SQL 2000 at my disposal. The value in the Unique field can only exist one time in the table, which is reall causing some problems.
This is how my table is put together.
CREATE TABLE [dbo].[MyTable] (
[part_id] [int] IDENTITY (1, 1) NOT NULL ,
[Unique] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[c_date] [datetime] NULL ,
[m_date] [datetime] NULL ,
[Qty] [int] NULL ,
[ht_num] [int] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[MyTable] WITH NOCHECK ADD
CONSTRAINT [PK_MyTable] PRIMARY KEY CLUSTERED
([part_id]) ON [PRIMARY]
GO
I have tried many different ways to merge these values into one single record and am failing. The values are for traceable parts, so I can not simply delete the duplicate records. Since the parts are recorded in the table every 10 to 15 minutes, the option of restoring a backup can not be done.
Does any one have a good idea that could accomplish this task?
I have spent three days trying to figure this out with no success.
Thank you,
Xavier