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

2012年3月11日星期日

bcp import of decimal data (long)

I am trying to import data from a flat file into a decimal(9,2) column. Here is the decimal data in each record of the flat file:

123456789

There is no decimal point in the field but last two positions represent the right of the decimal point, some fields have leading zeros)

I have discovered the following format file (extract) appears to do the import and place the decimal properly in the table column (1234567.89). Note the table column number and name are the same:

snip

11 SQLCHAR 0 7 "" 11 FieldName ""
12 SQLCHAR 0 2 "" 11 FieldName ""
snip

But bcp throws this error after a few seconds:

snip

C:\>bcp DatabeseName..Tablename in DataFileName.dat -fFormatFile.fmt -S.\SQLExpress -T

Starting copy...

SQLState = HY000, NativeError = 0

Error = [Microsoft][SQL Native Client]Unspecified error occurred

Connection may have been terminated by the server.

SQLState = 08S01, NativeError = 233

Error = [Microsoft][SQL Native Client]Shared Memory Provider: No

he other end of the pipe.

SQLState = 08S01, NativeError = 233

Error = [Microsoft][SQL Native Client]Communication link failure

SQLState = 08S01, NativeError = 0

Error = [Microsoft][SQL Native Client]Communication link failure

... (last two line repeated until abort)

BCP copy in failed

snip

For some reason the error does not occur with format files with different field formats. However other formats do not import properly.

Can someone identify this error or perhaps tell me how the above decimal format can be imported from a flat file as described? Any help is really appreciated as I have wasted several days already...TIA.

Sturdy

sturdy wrote:

I am trying to import data from a flat file into a decimal(9,2) column. Here is the decimal data in each record of the flat file:

123456789

There is no decimal point in the field but last two positions represent the right of the decimal point, some fields have leading zeros)

I have discovered the following format file (extract) appears to do the import and place the decimal properly in the table column (1234567.89). Note the table column number and name are the same:

snip

11 SQLCHAR 0 7 "" 11 FieldName ""
12 SQLCHAR 0 2 "" 11 FieldName ""
snip...

In the format file the destination column ordinal are supposed to be unique, except when the ordinal is 0. Hence the format file like this is wrong and BCP should have complained about it. Apparently, there must be a bug in the BCP format file parser and the parser misses the defect in the format file instead of failing the statement. Since the shape of TDS stream that comes to the SQL Engine from BCP is not what is expected, unltimately the statement still fails, but much later - when, possibly, much more serious damage is done, including silent corruptions of the data in the database. Thanks for discovering this.

Back to your original question - the bulk load format file is unable to provide you with the functionality you need. Essentially what you require is to specify an additional scaling factor for your integer input data. One suggestion that comes to mind - use SSIS (aka DTS). This is exactly the kind of a problem the SSIS/DTS was originally intended for.

|||

Thanks Tengez. At least that explains why I was having so much trouble ;-) The bcp/format file documentation is horrendous.

It is strange though, that the column numbers as I described does place the decimal correctly.

Sturdy

2012年3月8日星期四

bcp extract with , (comma) as decimal

Hello,
I am desperatly trying to export a table from my sql server.
Using bcp I only have my csv file with . as decimal for all numbers (I also
tried the export wizard of the sql console).
Is there a way to obtain these figures with a comma , as decimal?
The ddl of the table is below and numbers are stored in :
[number_value] [float]
CREATE TABLE [dbo].[table] (
[id] [int] NOT NULL ,
[id2] [int] NOT NULL ,
[date_lo] [smalldatetime] NOT NULL ,
[number_type] [int] NOT NULL ,
[is_estimated] [varchar] (2) NULL ,
[number_value] [float] NULL ,
[date_value] [smalldatetime] NULL ,
[string_value] [varchar] (255) NULL ,
[number_int_value] [int] NULL
) ON [PRIMARY]
GO
Thanks in advance for your help.
You can try DTS and edit the default transformation script to be like this
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
DTSDestination("number_value") = replace(DTSSource("number_value"),".",",")
' Do replacement here
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
Is this what you need?
Thanks,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
<grille11@.yahoo.com> wrote in message
news:cni2ha$88a$1@.reader1.imaginet.fr...
> Hello,
> I am desperatly trying to export a table from my sql server.
> Using bcp I only have my csv file with . as decimal for all numbers (I
> also
> tried the export wizard of the sql console).
> Is there a way to obtain these figures with a comma , as decimal?
> The ddl of the table is below and numbers are stored in :
> [number_value] [float]
>
> CREATE TABLE [dbo].[table] (
> [id] [int] NOT NULL ,
> [id2] [int] NOT NULL ,
> [date_lo] [smalldatetime] NOT NULL ,
> [number_type] [int] NOT NULL ,
> [is_estimated] [varchar] (2) NULL ,
> [number_value] [float] NULL ,
> [date_value] [smalldatetime] NULL ,
> [string_value] [varchar] (255) NULL ,
> [number_int_value] [int] NULL
> ) ON [PRIMARY]
> GO
>
> Thanks in advance for your help.
>
>
|||I have an error code: 0
description: Invalid use of Null: 'replace'
The first 40000 rows have a null value and the rest as a value with a
deciaml as .
Here is an example, the first row as no value and the one below has
1513.2527515762899 that need to be changed as 1513,2527515762899.
1;0;0;2004-02-27 00:00:00;3;0;N;;2004-02-27 00:00:00;;
1;1990;2;2003-01-09 00:00:00;5;0;N;1513.2527515762899;;;
"Mohamed Sharaf" <Mohamed.Sharaf@.egdsc.microsoft.com> wrote in message
news:uReyO5WzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> You can try DTS and edit the default transformation script to be like this
> Function Main()
> DTSDestination("id") = DTSSource("id")
> DTSDestination("id2") = DTSSource("id2")
> DTSDestination("date_lo") = DTSSource("date_lo")
> DTSDestination("number_type") = DTSSource("number_type")
> DTSDestination("is_estimated") = DTSSource("is_estimated")
> DTSDestination("number_value") =
replace(DTSSource("number_value"),".",",")
> ' Do replacement here
> DTSDestination("date_value") = DTSSource("date_value")
> DTSDestination("string_value") = DTSSource("string_value")
> DTSDestination("number_int_value") = DTSSource("number_int_value")
> Main = DTSTransformStat_OK
> End Function
> Is this what you need?
> Thanks,
> --
> Mohamed Sharaf
> MEA Developer Support Center
> ITWorx on behalf Microsoft EMEA GTSC
>
> <grille11@.yahoo.com> wrote in message
> news:cni2ha$88a$1@.reader1.imaginet.fr...
>

bcp extract with , (comma) as decimal

Hello,
I am desperatly trying to export a table from my sql server.
Using bcp I only have my csv file with . as decimal for all numbers (I also
tried the export wizard of the sql console).
Is there a way to obtain these figures with a comma , as decimal?
The ddl of the table is below and numbers are stored in :
[number_value] [float]
CREATE TABLE [dbo].[table] (
[id] [int] NOT NULL ,
[id2] [int] NOT NULL ,
[date_lo] [smalldatetime] NOT NULL ,
[number_type] [int] NOT NULL ,
[is_estimated] [varchar] (2) NULL ,
[number_value] [float] NULL ,
[date_value] [smalldatetime] NULL ,
[string_value] [varchar] (255) NULL ,
[number_int_value] [int] NULL
) ON [PRIMARY]
GO
Thanks in advance for your help.
You can try DTS and edit the default transformation script to be like this
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
DTSDestination("number_value") = replace(DTSSource("number_value"),".",",")
' Do replacement here
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
Is this what you need?
Thanks,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
<grille11@.yahoo.com> wrote in message
news:cni2ha$88a$1@.reader1.imaginet.fr...
> Hello,
> I am desperatly trying to export a table from my sql server.
> Using bcp I only have my csv file with . as decimal for all numbers (I
> also
> tried the export wizard of the sql console).
> Is there a way to obtain these figures with a comma , as decimal?
> The ddl of the table is below and numbers are stored in :
> [number_value] [float]
>
> CREATE TABLE [dbo].[table] (
> [id] [int] NOT NULL ,
> [id2] [int] NOT NULL ,
> [date_lo] [smalldatetime] NOT NULL ,
> [number_type] [int] NOT NULL ,
> [is_estimated] [varchar] (2) NULL ,
> [number_value] [float] NULL ,
> [date_value] [smalldatetime] NULL ,
> [string_value] [varchar] (255) NULL ,
> [number_int_value] [int] NULL
> ) ON [PRIMARY]
> GO
>
> Thanks in advance for your help.
>
>
|||I have an error code: 0
description: Invalid use of Null: 'replace'
The first 40000 rows have a null value and the rest as a value with a
deciaml as .
Here is an example, the first row as no value and the one below has
1513.2527515762899 that need to be changed as 1513,2527515762899.
1;0;0;2004-02-27 00:00:00;3;0;N;;2004-02-27 00:00:00;;
1;1990;2;2003-01-09 00:00:00;5;0;N;1513.2527515762899;;;
"Mohamed Sharaf" <Mohamed.Sharaf@.egdsc.microsoft.com> wrote in message
news:uReyO5WzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> You can try DTS and edit the default transformation script to be like this
> Function Main()
> DTSDestination("id") = DTSSource("id")
> DTSDestination("id2") = DTSSource("id2")
> DTSDestination("date_lo") = DTSSource("date_lo")
> DTSDestination("number_type") = DTSSource("number_type")
> DTSDestination("is_estimated") = DTSSource("is_estimated")
> DTSDestination("number_value") =
replace(DTSSource("number_value"),".",",")
> ' Do replacement here
> DTSDestination("date_value") = DTSSource("date_value")
> DTSDestination("string_value") = DTSSource("string_value")
> DTSDestination("number_int_value") = DTSSource("number_int_value")
> Main = DTSTransformStat_OK
> End Function
> Is this what you need?
> Thanks,
> --
> Mohamed Sharaf
> MEA Developer Support Center
> ITWorx on behalf Microsoft EMEA GTSC
>
> <grille11@.yahoo.com> wrote in message
> news:cni2ha$88a$1@.reader1.imaginet.fr...
>

bcp extract with , (comma) as decimal

Hello,
I am desperatly trying to export a table from my sql server.
Using bcp I only have my csv file with . as decimal for all numbers (I also
tried the export wizard of the sql console).
Is there a way to obtain these figures with a comma , as decimal?
The ddl of the table is below and numbers are stored in :
[number_value] [float]
CREATE TABLE [dbo].[table] (
[id] [int] NOT NULL ,
[id2] [int] NOT NULL ,
[date_lo] [smalldatetime] NOT NULL ,
[number_type] [int] NOT NULL ,
[is_estimated] [varchar] (2) NULL ,
[number_value] [float] NULL ,
[date_value] [smalldatetime] NULL ,
[string_value] [varchar] (255) NULL ,
[number_int_value] [int] NULL
) ON [PRIMARY]
GO
Thanks in advance for your help.
You can try DTS and edit the default transformation script to be like this
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
DTSDestination("number_value") = replace(DTSSource("number_value"),".",",")
' Do replacement here
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
Is this what you need?
Thanks,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
<grille11@.yahoo.com> wrote in message
news:cni2ha$88a$1@.reader1.imaginet.fr...
> Hello,
> I am desperatly trying to export a table from my sql server.
> Using bcp I only have my csv file with . as decimal for all numbers (I
> also
> tried the export wizard of the sql console).
> Is there a way to obtain these figures with a comma , as decimal?
> The ddl of the table is below and numbers are stored in :
> [number_value] [float]
>
> CREATE TABLE [dbo].[table] (
> [id] [int] NOT NULL ,
> [id2] [int] NOT NULL ,
> [date_lo] [smalldatetime] NOT NULL ,
> [number_type] [int] NOT NULL ,
> [is_estimated] [varchar] (2) NULL ,
> [number_value] [float] NULL ,
> [date_value] [smalldatetime] NULL ,
> [string_value] [varchar] (255) NULL ,
> [number_int_value] [int] NULL
> ) ON [PRIMARY]
> GO
>
> Thanks in advance for your help.
>
>
|||I have an error code: 0
description: Invalid use of Null: 'replace'
The first 40000 rows have a null value and the rest as a value with a
deciaml as .
Here is an example, the first row as no value and the one below has
1513.2527515762899 that need to be changed as 1513,2527515762899.
1;0;0;2004-02-27 00:00:00;3;0;N;;2004-02-27 00:00:00;;
1;1990;2;2003-01-09 00:00:00;5;0;N;1513.2527515762899;;;
"Mohamed Sharaf" <Mohamed.Sharaf@.egdsc.microsoft.com> wrote in message
news:uReyO5WzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> You can try DTS and edit the default transformation script to be like this
> Function Main()
> DTSDestination("id") = DTSSource("id")
> DTSDestination("id2") = DTSSource("id2")
> DTSDestination("date_lo") = DTSSource("date_lo")
> DTSDestination("number_type") = DTSSource("number_type")
> DTSDestination("is_estimated") = DTSSource("is_estimated")
> DTSDestination("number_value") =
replace(DTSSource("number_value"),".",",")
> ' Do replacement here
> DTSDestination("date_value") = DTSSource("date_value")
> DTSDestination("string_value") = DTSSource("string_value")
> DTSDestination("number_int_value") = DTSSource("number_int_value")
> Main = DTSTransformStat_OK
> End Function
> Is this what you need?
> Thanks,
> --
> Mohamed Sharaf
> MEA Developer Support Center
> ITWorx on behalf Microsoft EMEA GTSC
>
> <grille11@.yahoo.com> wrote in message
> news:cni2ha$88a$1@.reader1.imaginet.fr...
>
|||Hello,
This error happens because of null values so we can change the code
to become
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
if DTSSource("number_value")<>"" then
DTSDestination("number_value") =
replace(DTSSource("number_value"),".",",") ' Do replacement here
end if
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
I didn't try this code , so it may still needs some modifications, please
try it.
Best regards,
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC

bcp extract with , (comma) as decimal

Hello,
I am desperatly trying to export a table from my sql server.
Using bcp I only have my csv file with . as decimal for all numbers (I also
tried the export wizard of the sql console).
Is there a way to obtain these figures with a comma , as decimal?
The ddl of the table is below and numbers are stored in :
[number_value] [float]
CREATE TABLE [dbo].[table] (
[id] [int] NOT NULL ,
[id2] [int] NOT NULL ,
[date_lo] [smalldatetime] NOT NULL ,
[number_type] [int] NOT NULL ,
[is_estimated] [varchar] (2) NULL ,
[number_value] [float] NULL ,
[date_value] [smalldatetime] NULL ,
[string_value] [varchar] (255) NULL ,
[number_int_value] [int] NULL
) ON [PRIMARY]
GO
Thanks in advance for your help.You can try DTS and edit the default transformation script to be like this
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
DTSDestination("number_value") = replace(DTSSource("number_value"),".",",")
' Do replacement here
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
Is this what you need?
Thanks,
--
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
<grille11@.yahoo.com> wrote in message
news:cni2ha$88a$1@.reader1.imaginet.fr...
> Hello,
> I am desperatly trying to export a table from my sql server.
> Using bcp I only have my csv file with . as decimal for all numbers (I
> also
> tried the export wizard of the sql console).
> Is there a way to obtain these figures with a comma , as decimal?
> The ddl of the table is below and numbers are stored in :
> [number_value] [float]
>
> CREATE TABLE [dbo].[table] (
> [id] [int] NOT NULL ,
> [id2] [int] NOT NULL ,
> [date_lo] [smalldatetime] NOT NULL ,
> [number_type] [int] NOT NULL ,
> [is_estimated] [varchar] (2) NULL ,
> [number_value] [float] NULL ,
> [date_value] [smalldatetime] NULL ,
> [string_value] [varchar] (255) NULL ,
> [number_int_value] [int] NULL
> ) ON [PRIMARY]
> GO
>
> Thanks in advance for your help.
>
>|||I have an error code: 0
description: Invalid use of Null: 'replace'
The first 40000 rows have a null value and the rest as a value with a
deciaml as .
Here is an example, the first row as no value and the one below has
1513.2527515762899 that need to be changed as 1513,2527515762899.
1;0;0;2004-02-27 00:00:00;3;0;N;;2004-02-27 00:00:00;;
1;1990;2;2003-01-09 00:00:00;5;0;N;1513.2527515762899;;;
"Mohamed Sharaf" <Mohamed.Sharaf@.egdsc.microsoft.com> wrote in message
news:uReyO5WzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> You can try DTS and edit the default transformation script to be like this
> Function Main()
> DTSDestination("id") = DTSSource("id")
> DTSDestination("id2") = DTSSource("id2")
> DTSDestination("date_lo") = DTSSource("date_lo")
> DTSDestination("number_type") = DTSSource("number_type")
> DTSDestination("is_estimated") = DTSSource("is_estimated")
> DTSDestination("number_value") =
replace(DTSSource("number_value"),".",",")
> ' Do replacement here
> DTSDestination("date_value") = DTSSource("date_value")
> DTSDestination("string_value") = DTSSource("string_value")
> DTSDestination("number_int_value") = DTSSource("number_int_value")
> Main = DTSTransformStat_OK
> End Function
> Is this what you need?
> Thanks,
> --
> Mohamed Sharaf
> MEA Developer Support Center
> ITWorx on behalf Microsoft EMEA GTSC
>
> <grille11@.yahoo.com> wrote in message
> news:cni2ha$88a$1@.reader1.imaginet.fr...
>

bcp extract with , (comma) as decimal

Hello,
I am desperatly trying to export a table from my sql server.
Using bcp I only have my csv file with . as decimal for all numbers (I also
tried the export wizard of the sql console).
Is there a way to obtain these figures with a comma , as decimal?
The ddl of the table is below and numbers are stored in :
[number_value] [float]
CREATE TABLE [dbo].[table] (
[id] [int] NOT NULL ,
[id2] [int] NOT NULL ,
[date_lo] [smalldatetime] NOT NULL ,
[number_type] [int] NOT NULL ,
[is_estimated] [varchar] (2) NULL ,
[number_value] [float] NULL ,
[date_value] [smalldatetime] NULL ,
[string_value] [varchar] (255) NULL ,
[number_int_value] [int] NULL
) ON [PRIMARY]
GO
Thanks in advance for your help.You can try DTS and edit the default transformation script to be like this
Function Main()
DTSDestination("id") = DTSSource("id")
DTSDestination("id2") = DTSSource("id2")
DTSDestination("date_lo") = DTSSource("date_lo")
DTSDestination("number_type") = DTSSource("number_type")
DTSDestination("is_estimated") = DTSSource("is_estimated")
DTSDestination("number_value") = replace(DTSSource("number_value"),".",",")
' Do replacement here
DTSDestination("date_value") = DTSSource("date_value")
DTSDestination("string_value") = DTSSource("string_value")
DTSDestination("number_int_value") = DTSSource("number_int_value")
Main = DTSTransformStat_OK
End Function
Is this what you need?
Thanks,
--
Mohamed Sharaf
MEA Developer Support Center
ITWorx on behalf Microsoft EMEA GTSC
<grille11@.yahoo.com> wrote in message
news:cni2ha$88a$1@.reader1.imaginet.fr...
> Hello,
> I am desperatly trying to export a table from my sql server.
> Using bcp I only have my csv file with . as decimal for all numbers (I
> also
> tried the export wizard of the sql console).
> Is there a way to obtain these figures with a comma , as decimal?
> The ddl of the table is below and numbers are stored in :
> [number_value] [float]
>
> CREATE TABLE [dbo].[table] (
> [id] [int] NOT NULL ,
> [id2] [int] NOT NULL ,
> [date_lo] [smalldatetime] NOT NULL ,
> [number_type] [int] NOT NULL ,
> [is_estimated] [varchar] (2) NULL ,
> [number_value] [float] NULL ,
> [date_value] [smalldatetime] NULL ,
> [string_value] [varchar] (255) NULL ,
> [number_int_value] [int] NULL
> ) ON [PRIMARY]
> GO
>
> Thanks in advance for your help.
>
>|||I have an error code: 0
description: Invalid use of Null: 'replace'
The first 40000 rows have a null value and the rest as a value with a
deciaml as .
Here is an example, the first row as no value and the one below has
1513.2527515762899 that need to be changed as 1513,2527515762899.
1;0;0;2004-02-27 00:00:00;3;0;N;;2004-02-27 00:00:00;;
1;1990;2;2003-01-09 00:00:00;5;0;N;1513.2527515762899;;;
"Mohamed Sharaf" <Mohamed.Sharaf@.egdsc.microsoft.com> wrote in message
news:uReyO5WzEHA.1292@.TK2MSFTNGP10.phx.gbl...
> You can try DTS and edit the default transformation script to be like this
> Function Main()
> DTSDestination("id") = DTSSource("id")
> DTSDestination("id2") = DTSSource("id2")
> DTSDestination("date_lo") = DTSSource("date_lo")
> DTSDestination("number_type") = DTSSource("number_type")
> DTSDestination("is_estimated") = DTSSource("is_estimated")
> DTSDestination("number_value") =replace(DTSSource("number_value"),".",",")
> ' Do replacement here
> DTSDestination("date_value") = DTSSource("date_value")
> DTSDestination("string_value") = DTSSource("string_value")
> DTSDestination("number_int_value") = DTSSource("number_int_value")
> Main = DTSTransformStat_OK
> End Function
> Is this what you need?
> Thanks,
> --
> Mohamed Sharaf
> MEA Developer Support Center
> ITWorx on behalf Microsoft EMEA GTSC
>
> <grille11@.yahoo.com> wrote in message
> news:cni2ha$88a$1@.reader1.imaginet.fr...
> > Hello,
> >
> > I am desperatly trying to export a table from my sql server.
> > Using bcp I only have my csv file with . as decimal for all numbers (I
> > also
> > tried the export wizard of the sql console).
> > Is there a way to obtain these figures with a comma , as decimal?
> > The ddl of the table is below and numbers are stored in :
> >
> > [number_value] [float]
> >
> >
> >
> > CREATE TABLE [dbo].[table] (
> > [id] [int] NOT NULL ,
> > [id2] [int] NOT NULL ,
> > [date_lo] [smalldatetime] NOT NULL ,
> > [number_type] [int] NOT NULL ,
> > [is_estimated] [varchar] (2) NULL ,
> > [number_value] [float] NULL ,
> > [date_value] [smalldatetime] NULL ,
> > [string_value] [varchar] (255) NULL ,
> > [number_int_value] [int] NULL
> > ) ON [PRIMARY]
> > GO
> >
> >
> > Thanks in advance for your help.
> >
> >
> >
>

2012年2月25日星期六

BCP Cannot open database requested in login

I have several DB's that I am trying to bulk load with data using BCP
The problem is that all of them contain a decimal in the DB name.
When BCP runs it gets confused and tries to log on to just the first portion
of the database
For example with a DB named test.server I get the following error
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
requested in login 'test'. Login fails.
Is this just a limitation of BCP or is there some sort of work around?
Scott,
Quote it.
c:\>bcp "[my_db_with_._etc].dbo.t1" out "c:\temp\test.txt" ...
AMB
"Scott B" wrote:

> I have several DB's that I am trying to bulk load with data using BCP
> The problem is that all of them contain a decimal in the DB name.
> When BCP runs it gets confused and tries to log on to just the first portion
> of the database
> For example with a DB named test.server I get the following error
> SQLState = 37000, NativeError = 4060
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
> requested in login 'test'. Login fails.
> Is this just a limitation of BCP or is there some sort of work around?
>
>

BCP Cannot open database requested in login

I have several DB's that I am trying to bulk load with data using BCP
The problem is that all of them contain a decimal in the DB name.
When BCP runs it gets confused and tries to log on to just the first portion
of the database
For example with a DB named test.server I get the following error
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot op
en database
requested in login 'test'. Login fails.
Is this just a limitation of BCP or is there some sort of work around?Scott,
Quote it.
c:\>bcp "[my_db_with_._etc].dbo.t1" out "c:\temp\test.txt" ...
AMB
"Scott B" wrote:

> I have several DB's that I am trying to bulk load with data using BCP
> The problem is that all of them contain a decimal in the DB name.
> When BCP runs it gets confused and tries to log on to just the first porti
on
> of the database
> For example with a DB named test.server I get the following error
> SQLState = 37000, NativeError = 4060
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot
open database
> requested in login 'test'. Login fails.
> Is this just a limitation of BCP or is there some sort of work around?
>
>

BCP Cannot open database requested in login

I have several DB's that I am trying to bulk load with data using BCP
The problem is that all of them contain a decimal in the DB name.
When BCP runs it gets confused and tries to log on to just the first portion
of the database
For example with a DB named test.server I get the following error
SQLState = 37000, NativeError = 4060
Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
requested in login 'test'. Login fails.
Is this just a limitation of BCP or is there some sort of work around?Scott,
Quote it.
c:\>bcp "[my_db_with_._etc].dbo.t1" out "c:\temp\test.txt" ...
AMB
"Scott B" wrote:
> I have several DB's that I am trying to bulk load with data using BCP
> The problem is that all of them contain a decimal in the DB name.
> When BCP runs it gets confused and tries to log on to just the first portion
> of the database
> For example with a DB named test.server I get the following error
> SQLState = 37000, NativeError = 4060
> Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Cannot open database
> requested in login 'test'. Login fails.
> Is this just a limitation of BCP or is there some sort of work around?
>
>