SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


BCP native format data issue on import


BCP native format data issue on import

Author
Message
robinrai3
robinrai3
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 365
I am using bcp in native format to export a products table out
which has an integer primary key (NOTE it is not an IDENTITY) but with gaps in the id.

i.e i have 5878 rows and the product id at row 5878 stands at 6008


however when importing the data back on a different sql server... the product id is being
reset totally sequentially getting rid of the gaps in the id that were present
in the key so the max product id at row 5878 is now 5878...
and all product id's now match all the row numbers

the total rowcount is 5878 in both cases...

I cannot understand it as i am doing a native export and import
which is the defacto way of transferring sql server to sql server

i've checked it out a few times and it is still doing it

sql as below

select max(productsid) from products_target 5878
select max(productsid) from products_source 6008

select count(*) from products_target 5878
select count(*) from products_source 5878

any ideas ?
robinrai3
robinrai3
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 365
Hi All,

I've checked the target tables again and apologise but they do have identity fields...and that is what is causing the problem..the "bcp in" just generates sequential keys for the id column ignoring the source data for the id. I thought in native format the data being binary the bcp would ram home the data for this column. Any one know of setting the CHECK_IDENT_INSERT on type of flag (if there is one) for bcp ...

rgds

robin
Lowell
Lowell
One Orange Chip
One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)One Orange Chip (28K reputation)

Group: General Forum Members
Points: 28922 Visits: 39984
run bcp /? from the command prompt for all the possible flags;
i think the one you want is the -E flag:

-E keep identity values


Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

robinrai3
robinrai3
SSC-Enthusiastic
SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)SSC-Enthusiastic (192 reputation)

Group: General Forum Members
Points: 192 Visits: 365
thanks Lowell..it checks out
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search