|
Home > Archive > ASE Database forum > October 2005 > Numeric and Decimal datatype in BCP format file
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Numeric and Decimal datatype in BCP format file
|
|
| Jayeesh 2005-10-27, 8:21 am |
| Hi All,
I would like to know, have any one tried to take BCP out for
numeric or decimal datatype by using BCP format file.
Thanks in advance,
Regards,
-Jayeesh
| |
|
| > Hi All,
>
> I would like to know, have any one tried to take BCP out
> for numeric or decimal datatype by using BCP format file.
>
> Thanks in advance,
>
> Regards,
> -Jayeesh
Do you really want the out put file to contain the native
numeric/decimal data?
You can have bcp generate the .fmt file interactively by not
supplying a character mode. This can be done once, then the
.fmt file saved.
create table dbo.xx(
a decimal (3,2) not
null
, b decimal (10,2) not
null
)
bcp pubs2..xx out xx.dat -Uxxxxx -Pxxxxxxxx
Enter the file storage type of field a [decimal]:
Enter prefix-length of field a [1]:
Enter field terminator [none]:
Enter precision of field a [3]:
Enter scale of field a [2]:
Enter the file storage type of field b [decimal]:
Enter prefix-length of field b [1]:
Enter field terminator [none]:
Enter precision of field b [10]:
Enter scale of field b [2]:
Do you want to save this format information in a file? [Y/n]
y
Host filename [bcp.fmt]: xx.fmt
Starting copy...
18 rows copied.
The saved format file - xx.fmt:
10.0
2
1 SYBDECIMAL 1 5 "" 1 a
3 2
2 SYBDECIMAL 1 8 "" 2 b
10 2
When displayed, the data in the xx.dat file appears to be
gibberish.
I would normally convert the 2 columns to characters so that
the .dat file could be read.
10.0
2
1 SYBCHAR 0 5 "" 1 a
2 SYBCHAR 0 12 "\n" 2 b
~
|
|
|
|
|