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 Programming
 SQL Export & Importing

Author  Topic 

yoshi5
Starting Member

2 Posts

Posted - 2012-05-31 : 10:45:55
exporting

INSERT INTO `tbl_phonedir` (`firstname`, `lastname`, `extension`, `mailbox`, `loccode`, `email`, `record_id`) VALUES
('test', 'test', '4227', '4227', 'ACS', 'test@test.org', 334);

edit to import

INSERT INTO `tbl_phonedir` (`firstname`, `lastname`, `extension`, `mailbox`, `loccode`, `email`, `record_id`) VALUES
('edit', 'edit', '4227', '4227', 'ACS', 'edit@edit.org', 334);

i get a #1062 - Duplicate entry '334' for key 'PRIMARY'

i need to update 1000 things i am trying to export make the changes and import with out deleting everything first i am super new to this can any one help :D


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-05-31 : 10:55:34
SQLTeam.com is on MS SQL Server. Try posting over at forums.mysql.com or www.dbforums.com/mysql/


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

yoshi5
Starting Member

2 Posts

Posted - 2012-05-31 : 11:03:00
this is a ms sql server i am just using phpadmin to import and export dose that make a difference ?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-05-31 : 15:34:16
the error doesnt look like MS SQL standard error message.
I think the issue with your approach is you're trying to insert modified data without removing existing rows which is breaking PK constraint

The solutions are

1. Add a delete step to delete modified records first from main table and then do import of changes
2. Import to temporary staging table and do an update using this table to actual table. After each update operation truncate the temporary staging table

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

Go to Top of Page
   

- Advertisement -