dbTalk Databases Forums  

bcp out and bcp in don't give the same number of rows

microsoft.public.sqlserver.tools microsoft.public.sqlserver.tools


Discuss bcp out and bcp in don't give the same number of rows in the microsoft.public.sqlserver.tools forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
OJ
 
Posts: n/a

Default bcp out and bcp in don't give the same number of rows - 06-12-2004 , 08:35 AM






Hi,
I'm trying to export and import one big table in sql
server 2000 using bcp. Original table has 7,416,000 rows,
and after I bcp out this table into file in native format,
and bcp in from this file, also in native format, table
gets 7,478,000 rows and the data takes significantly less
space than before!
This table has char, varchar, numeric, datetime, and text
data types.
Can anybody tell me why the difference?
Thanks,
OJ

Reply With Quote
  #2  
Old   
Hari
 
Posts: n/a

Default Re: bcp out and bcp in don't give the same number of rows - 06-12-2004 , 11:32 AM






Hi,

Significatly less space:-
-------------------------

This is because your source table is fragmented heavily. The fragmentation
can be viwed by
DBCC SHOWCONTIG (Reger books online for info) command. By using this command
see the scan density, if the scan density is
too low than execute a DBCC DBREINDEX (Refer books online for usage and
info) command to remove the fragmention.
Cause for the fragmentation is because of the DML commands (Insert, Update
and Delete).

Row Difference:-
-----------------

This may be bause of the inconsistency in sysindexes table. Execute the
below command to correct the inconsistency
and give the correct rows in the table. (Use the source table_name)

USE <dbname>
go
sp_spaceused <table_name>,@updateusage = 'TRUE'

--
Thanks
Hari
MCDBA
"OJ" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi,
I'm trying to export and import one big table in sql
server 2000 using bcp. Original table has 7,416,000 rows,
and after I bcp out this table into file in native format,
and bcp in from this file, also in native format, table
gets 7,478,000 rows and the data takes significantly less
space than before!
This table has char, varchar, numeric, datetime, and text
data types.
Can anybody tell me why the difference?
Thanks,
OJ



Reply With Quote
  #3  
Old   
OJ
 
Posts: n/a

Default Re: bcp out and bcp in don't give the same number of rows - 06-12-2004 , 04:02 PM



Table is not fragmented at all. It is rebuilt before bcp
out. Statistics are also updated because of rebuilding the
table (clustered index with fillfactor 100)...
Thanks anyway,
OJ
Quote:
-----Original Message-----
Hi,

Significatly less space:-
-------------------------

This is because your source table is fragmented heavily.
The fragmentation
can be viwed by
DBCC SHOWCONTIG (Reger books online for info) command. By
using this command
see the scan density, if the scan density is
too low than execute a DBCC DBREINDEX (Refer books online
for usage and
info) command to remove the fragmention.
Cause for the fragmentation is because of the DML
commands (Insert, Update
and Delete).

Row Difference:-
-----------------

This may be bause of the inconsistency in sysindexes
table. Execute the
below command to correct the inconsistency
and give the correct rows in the table. (Use the source
table_name)

USE <dbname
go
sp_spaceused <table_name>,@updateusage = 'TRUE'

--
Thanks
Hari
MCDBA
"OJ" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:1b69d01c45082$2712ca90$a301280a (AT) phx (DOT) gbl...
Hi,
I'm trying to export and import one big table in sql
server 2000 using bcp. Original table has 7,416,000
rows,
and after I bcp out this table into file in native
format,
and bcp in from this file, also in native format, table
gets 7,478,000 rows and the data takes significantly
less
space than before!
This table has char, varchar, numeric, datetime, and
text
data types.
Can anybody tell me why the difference?
Thanks,
OJ


.


Reply With Quote
  #4  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: bcp out and bcp in don't give the same number of rows - 06-13-2004 , 06:17 PM



OJ (anonymous (AT) discussions (DOT) microsoft.com) writes:
Quote:
Table is not fragmented at all. It is rebuilt before bcp
out. Statistics are also updated because of rebuilding the
table (clustered index with fillfactor 100)...
How was it rebuilt? I've seen that when I have run DBCC DBREINDEX, there
has been a lot of extra space around, as it to have room next time
DBREINDEX is run.

How did you conclude that the number of rows were different? Did you
actually run a SELECT COUNT(*)? Or did you look at sysindexes.rows?
To get accurate values in this column - and in the space column,
run DBCC UPDATEUSAGE on the table.

If you indeed get different results with SELECT COUNT(*) before and
after running BCP, something is fishy. One alternative is that there
was some other data in the target table before you started. Also
check that the schemas of the tables are entirely identical.

--
Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.