ARGGH!!!
I have a table with a combined Primary Key, ValidProductID and OverRemitID. I'm trying to do an insert with hardcoded values, but the insert is acting strangely and duplicated 4 of the 6 records.
The pre-insert recordset looks like this:
VPID ORID Amt CreatedBy CreatedOn
426638 713 10 ITS-ME 2005-08-26 09:38:30.497
426638 1101 30 ITS-ME 2005-08-26 09:38:30.497
426639 713 10 ITS-ME 2005-08-26 09:38:30.497
426639 1101 30 ITS-ME 2005-08-26 09:38:30.497
Here's the Insert Statement:
When I do the insert, I get the message back (6 rows affected). When I do a selecct on the table, the records for 426637 (which has no pre-existing records) inserts fine, but the records for 426638 and 426639 have each inserted twice, giving me 10 new records instead of the 6 records SQL Server has said I inserted!
New RecordSet:
VPID ORID Amt CreatedBy CreatedOn
426637 942 280 ITS-ME 2005-08-26 09:38:30.497
426637 1132 120 ITS-ME 2005-08-26 09:38:30.497
426638 713 100 ITS-ME 2005-08-26 09:38:30.497
426638 942 280 ITS-ME 2005-08-26 09:38:30.497
426638 942 280 ITS-ME 2005-08-26 09:38:30.497
426638 1101 300 ITS-ME 2005-08-26 09:38:30.497
426638 1132 120 ITS-ME 2005-08-26 09:38:30.497426638 1132 120 ITS-ME 2005-08-26 09:38:30.497426639 713 100 ITS-ME 2005-08-26 09:38:30.497
426639 942 280 ITS-ME 2005-08-26 09:38:30.497
426639 942 280 ITS-ME 2005-08-26 09:38:30.497
426639 1101 300 ITS-ME 2005-08-26 09:38:30.497
426639 1132 120 ITS-ME 2005-08-26 09:38:30.497
426639 1132 120 ITS-ME 2005-08-26 09:38:30.497
I've never seen this happen before with a hard coded value list. I've seen it, with an Insert stmt using a join to a multiple record table, but never when I supply the values to the table.
Does anyone have a clue what is happening here? I can repeat this ad-naseum all day. And yes, I know I can insert the records individually (that's what I'm going to do right now), but I'd like to know what caused this in the first place.
Thanks in advance!!!
Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
I have a table with a combined Primary Key, ValidProductID and OverRemitID. I'm trying to do an insert with hardcoded values, but the insert is acting strangely and duplicated 4 of the 6 records.
The pre-insert recordset looks like this:
VPID ORID Amt CreatedBy CreatedOn
426638 713 10 ITS-ME 2005-08-26 09:38:30.497
426638 1101 30 ITS-ME 2005-08-26 09:38:30.497
426639 713 10 ITS-ME 2005-08-26 09:38:30.497
426639 1101 30 ITS-ME 2005-08-26 09:38:30.497
Here's the Insert Statement:
Code:
Insert into tblOverRemit (ValidProductID, OverRemitID,
OverRemitAmount, CreatedBy, CreatedOn, EntryDate, ModifiedBy, ModifiedOn)
(Select 426637, 942, 28.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
union
(Select 426637, 1132, 12.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
union
(Select 426638, 942, 28.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
union
(Select 426638, 1132, 12.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
union
(Select 426639, 942, 28.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
union
(Select 426639, 1132, 12.0000, 'ITS-ME', '2005-08-26 09:38:30.497', NULL as EntryDate, NULL as ModifiedBy, NULL as ModifiedOn)
When I do the insert, I get the message back (6 rows affected). When I do a selecct on the table, the records for 426637 (which has no pre-existing records) inserts fine, but the records for 426638 and 426639 have each inserted twice, giving me 10 new records instead of the 6 records SQL Server has said I inserted!
New RecordSet:
VPID ORID Amt CreatedBy CreatedOn
426637 942 280 ITS-ME 2005-08-26 09:38:30.497
426637 1132 120 ITS-ME 2005-08-26 09:38:30.497
426638 713 100 ITS-ME 2005-08-26 09:38:30.497
426638 942 280 ITS-ME 2005-08-26 09:38:30.497
426638 942 280 ITS-ME 2005-08-26 09:38:30.497
426638 1101 300 ITS-ME 2005-08-26 09:38:30.497
426638 1132 120 ITS-ME 2005-08-26 09:38:30.497426638 1132 120 ITS-ME 2005-08-26 09:38:30.497426639 713 100 ITS-ME 2005-08-26 09:38:30.497
426639 942 280 ITS-ME 2005-08-26 09:38:30.497
426639 942 280 ITS-ME 2005-08-26 09:38:30.497
426639 1101 300 ITS-ME 2005-08-26 09:38:30.497
426639 1132 120 ITS-ME 2005-08-26 09:38:30.497
426639 1132 120 ITS-ME 2005-08-26 09:38:30.497
I've never seen this happen before with a hard coded value list. I've seen it, with an Insert stmt using a join to a multiple record table, but never when I supply the values to the table.
Does anyone have a clue what is happening here? I can repeat this ad-naseum all day. And yes, I know I can insert the records individually (that's what I'm going to do right now), but I'd like to know what caused this in the first place.
Thanks in advance!!!
Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???