August 7, 2008 at 12:51 am
Dear friends,
Good afternoon,
any one can help me to find out solution for the following issue.
issue is:-
Table consist of 12 columns out of this 6 columns consists of composte primary key.
the 6 colums of the table like this
AL_ALIDAL_ALTYP AL_PROJ AL_AGID AL_AGTY PAL_CITID
121131
121231
121132
121235
Till here its working fine,after inserting this row it dispalying the error mesaage like
Error source:-.Netsqlclientdataprovider
errormessage:-Voilation of primarykey constarint,cannot insert duplicate value.
the new row is
221131
Thanks & Regards
rclgoriparthi
August 7, 2008 at 1:23 am
Maybe I'm wrong, but it looks like the first row already in your table.
Am I missing something?
-- Gianluca Sartori
August 7, 2008 at 1:57 am
First make sure that your table indeed has the columns you want to be in the pk as the pk columns:
SELECT i.name
, ic.index_column_id
, c.name
FROM sys.indexes i
JOIN sys.index_columns ic ON i.[object_id] = ic.[object_id]
AND i.index_id = ic.index_id
JOIN sys.columns c ON ic.[object_id] = c.[object_id]
AND ic.column_id = c.column_id
WHERE i.object_id = OBJECT_ID('mytable')
AND i.is_primary_key = 1
ORDER BY key_ordinal
Then, have a look at your insert statement. Are you specifying the columns that should be inserted. Is the order of these the same as the order of the data values? Try selecting from the table the columns in the same order as in your insert statement column listing.
Regards,
Andras
August 7, 2008 at 1:59 am
difference between the first row and last row is except first column,
both the rows are same except first column
Rgds,
rclgoriparthi
August 7, 2008 at 6:10 am
You may need to post your code because that should work fine. As one of the previous posts said, you may have your PK improperly defined.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply