Re: BULK COPY changes row order importing Text file

From: Uri Dimant (urid_at_iscar.co.il)
Date: 02/19/04


Date: Thu, 19 Feb 2004 14:02:02 +0200

lindawie
After running this command bcp zap..authors_staging in
authors2.dat -fauthors.bcp -S. -T

NULL
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 = 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 = 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 = 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 = 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
NULL
BCP copy in failed
NULL

"lindawie" <lindawie@my-deja.com> wrote in message
news:##D00Is9DHA.3292@TK2MSFTNGP11.phx.gbl...
> Steve,
>
> > One possibility is to add line numbers with
> >
> > C:\> find /V /N "" c:\tempo\prueba.txt > c:\tempo\prueba2.txt
>
>
> Very nice idea! I wish I'd thought of that. :)
>
> We can refine your idea a bit to avoid those extra lines in the
> output file. FINDSTR has more options than FIND, so I would use that
> instead.
>
> This command line adds line numbers delimited by a colon, but
> doesn't add any extra lines to the output file.
>
> findstr /N /C:. authors.dat > authors2.dat
>
> We can then use a bcp format file to load the data into a table with
> separate columns for each file in the file.
>
>
>
> Here's a sorta complete repro
>
> use pubs
> go
>
> -- Create a staging table with a line_nbr column.
> select 1 as line_nbr, *
> into authors_staging
> from pubs..authors
> where 0 = 1
>
> exec sp_help pubs..authors
>
>
> -- Create a tab-delimited data file.
> bcp pubs..authors out authors.dat -c -S. -T
>
> -- Add line numbers to the data file.
> findstr /N /C:. authors.dat > authors2.dat
>
>
> -- Create a format file.
> bcp pubs..authors_staging format nul -fauthors.bcp -c -S. -T
>
>
> -- Edit the first line for the colon delimiter.
> 8.0
> 10
> 1 SQLCHAR 0 12 ":" 1 line_nbr ""
> 2 SQLCHAR 0 11 "\t" 2 au_id ""
> 3 SQLCHAR 0 40 "\t" 3 au_lname ""
> 4 SQLCHAR 0 20 "\t" 4 au_fname ""
> 5 SQLCHAR 0 12 "\t" 5 phone ""
> 6 SQLCHAR 0 40 "\t" 6 address ""
> 7 SQLCHAR 0 20 "\t" 7 city ""
> 8 SQLCHAR 0 2 "\t" 8 state ""
> 9 SQLCHAR 0 5 "\t" 9 zip ""
> 10 SQLCHAR 0 3 "\r\n" 10 contract ""
>
>
> -- Load the file into the staging table.
> bcp zap..authors_staging in authors2.dat -fauthors.bcp -S. -T
>
>
> select * from authors_staging
>
>
> -- Linda
>
>



Relevant Pages

  • error from trasational repl
    ... it show me this error "[ODBC SQL Server Driver]Invalid character value for cast ... can anyone tell me some hints or I can't do this action directly as i want to find what error about this query. ...
    (microsoft.public.sqlserver.replication)
  • Re: ADO return varchar string with space trimmed
    ... > Cast to charwork. ... A varcharfield is a variable character length, ... I've only worked with SQL Server and MS Access. ... Dan ...
    (microsoft.public.data.ado)
  • Re: Development news catch-up
    ... to topline a new original movie for the cable channel, ... Does Ponce have the chops to be the lead/recurring character? ... 10-to-1 says this means a new cast. ... "Summerland") is the latest addition to the comedy pilot, ...
    (rec.arts.tv)
  • Re: The importance of Kid Vulcan as a new X-Man?
    ... successful addition to the X-Men cast, primarily as a new X-Man. ... character will be the one to break this rut. ... Will it be Kid Vulcan? ... He's set to be the driver of the first Brubaker written Uncanny X-Men ...
    (rec.arts.comics.marvel.xbooks)
  • Re: The importance of Kid Vulcan as a new X-Man?
    ... successful addition to the X-Men cast, primarily as a new X-Man. ... character will be the one to break this rut. ... Will it be Kid Vulcan? ... He's set to be the driver of the first Brubaker written Uncanny X-Men ...
    (rec.arts.comics.marvel.xbooks)