Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
my2003
Starting Member
2 Posts |
Posted - 2007-10-18 : 11:03:06
|
| Hi,I am using bcp to copy some data from a flat file to a data table using the format file that look like this.9.071 SQLCHAR 0 4 "" 1 Col1 SQL_Latin1_General_CP1_CI_AS2 SQLCHAR 0 9 "" 2 Col2 SQL_Latin1_General_CP1_CI_AS3 SQLCHAR 0 8 "" 3 Col3 ""4 SQLCHAR 0 7 "\n" 4 Col4 SQL_Latin1_General_CP1_CI_ASThere are 4 columns in total, however some rows have missing values for Column 4, and but given there are no field separators (all columns have fixed width and data is truncated if needed), how should the format be written to define a row terminator to apply to Column 3 if Column 4 is null. Thanks for your suggestions. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
my2003
Starting Member
2 Posts |
Posted - 2007-10-18 : 12:13:14
|
| Hi Brett,A sample data file that I am using is:EA MESSAGE0019010101C2B711EA MESSAGE0019010101EA MESSAGE0019010101M053519In this case the the 1st row and 3rd row both have values C2B711 and M053519 for Col 4, but the the 2nd one doesn't. There's no spaces that follow even though Col 4 defines a fixed width of 7. This produces an error and prevents its from being copied. How can I make sure it gets copied into the data table with a null for this empty field?Thanks, |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|
|