Question

I am running a bulk copy of two columns of a table from one server to another.

The table on the source side has about 8 columns, but I only need 2.

The table on the destination side has 2 columns (the two that I need, both are of type int)

Both databases are SQL Server 2005.

Here's my two bcp commands:

c:\> bcp "select c1, c2 from srcTable" queryout tableData.bcp -N -T -S srcServer
c:\> bcp destTable in tableData.bcp -N -T -S destServer

Why does this corrupt the data in the destination table? I should be getting nice, sequential integers, instead I get this:

c1          c2
586332      83014148
123128736   -105042384
-561616278  -309997736

What am I doing wrong?

Was it helpful?

Solution

Got it.

The column definition must match exactly - including whether it is NULL or NOT NULL.

The source had:

srcTable (
c1 int not null (PK)
c2 int null
c3 datetime not null
c4 datetime null
...
)

The destination table had:

destTable (
c1 int not null (PK)
c2 int not null 
)

The NOT NULL on destTable.c2 was the bug.

It's been squashed now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top