dbTalk Databases Forums  

Bcp and datatypes

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Bcp and datatypes in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rulle
 
Posts: n/a

Default Bcp and datatypes - 11-06-2003 , 09:19 AM






Hi!

I want to import a tab separated textfile to a SQL 2000
table. The row terminator in the textfile is newline.
Funlayer.txt:

Value1 003
Value2 4,7625
value3 7,0000
*************************************

Commandline:
bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -r\n -
fbcp.fmt
***********************************

bcp.fmt file:
8.0
3
1 SQLINT 0
0 "" 1
ID ""
2 SQLCHAR 0
50 "\t" 2 MNummer
Finnish_Swedish_CI_AS
3 SQLCHAR 0
50 "\t" 3 InnerDiam
Finnish_Swedish_CI_AS
**********************************************

--Db table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FunLayer]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[FunLayer]
GO

CREATE TABLE [dbo].[FunLayer] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[MNummer] [varchar] (50) COLLATE
Finnish_Swedish_CI_AS NULL ,
[InnerDiam] [decimal](18, 3) NULL
) ON [PRIMARY]
GO
****************************************
Errormessage:
Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF
encountered in BCP data-file

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 10
****************************

How can I make it work...?

Thanks!


Reply With Quote
  #2  
Old   
Ryan Waight
 
Posts: n/a

Default Re: Bcp and datatypes - 11-06-2003 , 11:00 AM






I haven't tested but give this a try :-

bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -c -t\t -fbcp.fmt

alternitavly consider loading the data with DTS


--
HTH
Ryan Waight, MCDBA, MCSE

"Rulle" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi!

I want to import a tab separated textfile to a SQL 2000
table. The row terminator in the textfile is newline.
Funlayer.txt:

Value1 003
Value2 4,7625
value3 7,0000
*************************************

Commandline:
bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -r\n -
fbcp.fmt
***********************************

bcp.fmt file:
8.0
3
1 SQLINT 0
0 "" 1
ID ""
2 SQLCHAR 0
50 "\t" 2 MNummer
Finnish_Swedish_CI_AS
3 SQLCHAR 0
50 "\t" 3 InnerDiam
Finnish_Swedish_CI_AS
**********************************************

--Db table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FunLayer]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[FunLayer]
GO

CREATE TABLE [dbo].[FunLayer] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[MNummer] [varchar] (50) COLLATE
Finnish_Swedish_CI_AS NULL ,
[InnerDiam] [decimal](18, 3) NULL
) ON [PRIMARY]
GO
****************************************
Errormessage:
Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF
encountered in BCP data-file

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 10
****************************

How can I make it work...?

Thanks!




Reply With Quote
  #3  
Old   
Jeff Block
 
Posts: n/a

Default Re: Bcp and datatypes - 11-06-2003 , 11:39 AM




you don't need the format file since its default tab and line feed and file
type is plain text

bcp test..funlayer in funlayer.txt -T -Slocalhost -c
"Rulle" <anonymous (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi!

I want to import a tab separated textfile to a SQL 2000
table. The row terminator in the textfile is newline.
Funlayer.txt:

Value1 003
Value2 4,7625
value3 7,0000
*************************************

Commandline:
bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -r\n -
fbcp.fmt
***********************************

bcp.fmt file:
8.0
3
1 SQLINT 0
0 "" 1
ID ""
2 SQLCHAR 0
50 "\t" 2 MNummer
Finnish_Swedish_CI_AS
3 SQLCHAR 0
50 "\t" 3 InnerDiam
Finnish_Swedish_CI_AS
**********************************************

--Db table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FunLayer]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[FunLayer]
GO

CREATE TABLE [dbo].[FunLayer] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[MNummer] [varchar] (50) COLLATE
Finnish_Swedish_CI_AS NULL ,
[InnerDiam] [decimal](18, 3) NULL
) ON [PRIMARY]
GO
****************************************
Errormessage:
Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected EOF
encountered in BCP data-file

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 10
****************************

How can I make it work...?

Thanks!




Reply With Quote
  #4  
Old   
Rulle
 
Posts: n/a

Default Re: Bcp and datatypes - 11-07-2003 , 12:58 AM



I've tried the your suggested command. It seems that it
can not interpret the newline character correctly. Any
ideas?

bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -c

Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 1


/Rulle

Quote:
-----Original Message-----

you don't need the format file since its default tab and
line feed and file
type is plain text

bcp test..funlayer in funlayer.txt -T -Slocalhost -c
"Rulle" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:0bb301c3a479$66822870$a601280a (AT) phx (DOT) gbl...
Hi!

I want to import a tab separated textfile to a SQL 2000
table. The row terminator in the textfile is newline.
Funlayer.txt:

Value1 003
Value2 4,7625
value3 7,0000
*************************************

Commandline:
bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -r\n -
fbcp.fmt
***********************************

bcp.fmt file:
8.0
3
1 SQLINT 0
0 "" 1
ID ""
2 SQLCHAR 0
50 "\t" 2 MNummer
Finnish_Swedish_CI_AS
3 SQLCHAR 0
50 "\t" 3 InnerDiam
Finnish_Swedish_CI_AS
**********************************************

--Db table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FunLayer]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[FunLayer]
GO

CREATE TABLE [dbo].[FunLayer] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[MNummer] [varchar] (50) COLLATE
Finnish_Swedish_CI_AS NULL ,
[InnerDiam] [decimal](18, 3) NULL
) ON [PRIMARY]
GO
****************************************
Errormessage:
Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected
EOF
encountered in BCP data-file

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 10
****************************

How can I make it work...?

Thanks!



.


Reply With Quote
  #5  
Old   
Rulle
 
Posts: n/a

Default Re: Bcp and datatypes - 11-07-2003 , 03:25 AM



I've found the problem, in the textfile the decimal
numbers are delimited with a decimal (,) but the SQL-
server expects a dot (.). I guess I have to convert the
textfile. Or is there any configuration in SQL server that
could resolve the problem?

Thanks!

Quote:
-----Original Message-----
I've tried the your suggested command. It seems that it
can not interpret the newline character correctly. Any
ideas?

bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -c

Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 1


/Rulle

-----Original Message-----

you don't need the format file since its default tab and
line feed and file
type is plain text

bcp test..funlayer in funlayer.txt -T -Slocalhost -c
"Rulle" <anonymous (AT) discussions (DOT) microsoft.com> wrote in
message
news:0bb301c3a479$66822870$a601280a (AT) phx (DOT) gbl...
Hi!

I want to import a tab separated textfile to a SQL 2000
table. The row terminator in the textfile is newline.
Funlayer.txt:

Value1 003
Value2 4,7625
value3 7,0000
*************************************

Commandline:
bcp TEST..FunLayer in FunLayer.txt -Slocalhost -T -
r\n -
fbcp.fmt
***********************************

bcp.fmt file:
8.0
3
1 SQLINT 0
0 "" 1
ID ""
2 SQLCHAR 0
50 "\t" 2 MNummer
Finnish_Swedish_CI_AS
3 SQLCHAR 0
50 "\t" 3 InnerDiam
Finnish_Swedish_CI_AS
**********************************************

--Db table
if exists (select * from dbo.sysobjects where id =
object_id(N'[dbo].[FunLayer]') and OBJECTPROPERTY(id,
N'IsUserTable') = 1)
drop table [dbo].[FunLayer]
GO

CREATE TABLE [dbo].[FunLayer] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[MNummer] [varchar] (50) COLLATE
Finnish_Swedish_CI_AS NULL ,
[InnerDiam] [decimal](18, 3) NULL
) ON [PRIMARY]
GO
****************************************
Errormessage:
Starting copy...
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = 22005, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Invalid
character value for cast specification
SQLState = S1000, NativeError = 0
Error = [Microsoft][ODBC SQL Server Driver]Unexpected
EOF
encountered in BCP data-file

1 rows copied.
Network packet size (bytes): 4096
Clock Time (ms.): total 10
****************************

How can I make it work...?

Thanks!



.

.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.