Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 insert statement

Author  Topic 

dtrivedi
Posting Yak Master

153 Posts

Posted - 2011-01-24 : 11:20:24
I am inserting rows from one table to another. here is the insert statement


insert into tsysIPScanRanges select * from Sheet1$;

I am getting this error what do i need to do...
Msg 2627, Level 14, State 1, Line 1
Violation of PRIMARY KEY constraint 'PK_tsysIPScanRanges'. Cannot insert duplicate key in object 'dbo.tsysIPScanRanges'.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-24 : 11:53:29
check whats the primary key of table. and make sure you avoid records of duplicate values for Primary key column coming from the sheet.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-25 : 03:27:39
You need to select the data from Sheet1$ which are not available in tsysIPScanRanges

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -