显示标签为“urgent”的博文。显示所有博文
显示标签为“urgent”的博文。显示所有博文

2012年3月19日星期一

BCP -k option - Very urgent

Hi Everyone,

I tried to bcp in the data file to a table in sqlserver 2000.
The data file has got few blanks in certain columns.
My requirement is all those blanks has to be converted null while bcp
in the data.

1. I have tried giving the option -k - Didn't work
2. I have tried creating a format file with prefix length 2 i.e as the
column is character.
3. Initially it was giving string data truncation error due to the
service pack3. Then I updated the service pack 3 also.

Pls someone help me out as this is very critical.

Thanks,
GaneshHi

An empty string is not the same as a null value. The -k option will not help
you with that. If you want to ignore the whole column then you can use the
format file to ignore the column. If you want to change these values after
loading use a subsequent update statement.

John

"Ganesh Babu" <ganesh.kaliaperumal@.wipro.com> wrote in message
news:35f45fe8.0407130502.37f14ad0@.posting.google.c om...
> Hi Everyone,
> I tried to bcp in the data file to a table in sqlserver 2000.
> The data file has got few blanks in certain columns.
> My requirement is all those blanks has to be converted null while bcp
> in the data.
> 1. I have tried giving the option -k - Didn't work
> 2. I have tried creating a format file with prefix length 2 i.e as the
> column is character.
> 3. Initially it was giving string data truncation error due to the
> service pack3. Then I updated the service pack 3 also.
> Pls someone help me out as this is very critical.
> Thanks,
> Ganesh

2012年3月11日星期日

bcp importing data from fewer fields to more table columns

Hello, please help me with this urgent problem,

I am trying to migrate data from one database to another using the bcp utility. Nowhere in the net I was able to find documentation on how to perform data importation when the destination table has more columns than the fields in my data file. I have a origin table which has 5 columns, and I need to migrate this data to a table that has 20 columns. How to do this? of course I need that the remaining 15 columns of the destination table be filled with NULL data.


From what I have seen, it seems that my xml format file must always have the same amount of <COLUMN> elements than the number of columns in the destination table, is this always so?. If it is, this is a real problem, since I lack 15 <COLUMN> elements in my format file.
I really don't know what can I do about this, pelase help!!

Thanks in advance,
Diego V.

Create a VIEW with the table.columns that match the data file, and BCP into the VIEW. (Be sure the other columns allow NULL values and/or have DEFAULT values.