Discussion:
BCP - Error - SQL Server native client - Invalid character value for cast specification
(too old to reply)
Chaz
2015-09-16 20:16:39 UTC
Permalink
When running BCP, I am getting an error. SQLState = 22005, NativeError = 0

Exporting the data from a single table works fine:

bcp [BWC.Dev].dbo.commentdatatemp out commentdatatemp.dat -c -T
-Spe-tp-sql1d\tp -t"||" -r"\\n" -E -w

truncating the data and running the following returns the error:

bcp [BWC.Dev].dbo.commentdatatemp in commentdatatemp.dat -c -T
-Spe-tp-sql1d\tp -t"||" -r"\\n" -E -w
Erland Sommarskog
2015-09-16 21:04:59 UTC
Permalink
Post by Chaz
When running BCP, I am getting an error. SQLState = 22005, NativeError = 0
bcp [BWC.Dev].dbo.commentdatatemp out commentdatatemp.dat -c -T
-Spe-tp-sql1d\tp -t"||" -r"\\n" -E -w
bcp [BWC.Dev].dbo.commentdatatemp in commentdatatemp.dat -c -T
-Spe-tp-sql1d\tp -t"||" -r"\\n" -E -w
Please post:

1) Output from "SELECT @@version"
2) CREATE TABLE statement for your tables.
3) INSERT statements with sample data that demonstrates the problem.
Alternatively, upload the output file somewhere (SkyDrive, GoogleDrive etc).

Without knowing anything of this, it is impossible to know.
--
Erland Sommarskog, Stockholm, ***@sommarskog.se
Chaz
2015-09-16 21:30:52 UTC
Permalink
1) Version:
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)

Found the error changed column delimiter to: -t"/\t"
Erland Sommarskog
2015-09-17 07:05:58 UTC
Permalink
Post by Chaz
Microsoft SQL Server 2012 - 11.0.5058.0 (X64)
May 14 2014 18:34:29
Copyright (c) Microsoft Corporation
Standard Edition (64-bit) on Windows NT 6.3 <X64> (Build 9600: ) (Hypervisor)
Found the error changed column delimiter to: -t"/\t"
Sounds like that the string || appeared in some row.
--
Erland Sommarskog, SQL Server MVP, ***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Loading...