recently i started dealing with sql server, before it was only msaccess.

when i'm doing import/export of a db, from the server to my computer or even in the server, all column with primary key loose the key. identity set to false and even bit is not set to the default

what can be done so import/export will make an exact copy of the db and its data and not doing backup and restore everytime i want the same db somewhere else or for another project or something like that

i have read about the "edit mapping" and the checkbox but that did not helped with the identity specification... and what about the primary key of the tables and the rest of the things?

link|improve this question

33% accept rate
1  
Why do you think import/exüort is better than backup/restore? – gbn Aug 28 '11 at 18:33
marc_s: i export from one sql server to another, duh! @gbn: i don't think so, it is just easier to export from one place to another without the need to backup, upload the backup file to the server and restore it – Y.G.J Aug 28 '11 at 18:35
1  
Again - that's not a method that will work most of the time. It will copy the data and the bare-bones structure - but none of the constraints, identity specs and so forth. That's the way it is. I would also recommend backup/restore, which WILL preserve your settings and everything. – marc_s Aug 28 '11 at 18:40
1  
@Y.G.J: you're new with SQL Server and know better then the folk who answer your questions? Interesting approach... – gbn Aug 28 '11 at 19:24
1  
@YGJ, meh, just use a SQL Data Compare or equivalent tool and it's a moot point. May as well get on with actual development – Brian Webster Aug 28 '11 at 19:37
show 2 more comments
feedback

migrated from stackoverflow.com Aug 29 '11 at 7:35

This question came from our site for professional and enthusiast programmers.

1 Answer

If you use SQL Data Compare, your identity columns will be maintained.

This really is the best way to keep DB's synced up perfectly and it comes highly recommended by the Stackoverflow founders.

It is generally a losing battle to try to use the built-in Import / Export functionality in SSMS

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.