Results 1 to 8 of 8

Thread: Bcp

  1. #1
    Join Date
    Aug 2007
    Posts
    18

    Unanswered: Bcp

    Can anybody give solution to this error message:
    Error = [Microsoft][ODBC SQL Server Driver]Invalid character value for cast specification

  2. #2
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    yep, i can

    Delete the invalid character in the cast specification

    OR

    Try pasting it into
    "www" and than a "dot" and then "google" and a "dot" again and then "com"
    hit the enter key end you'll get all kinds of results its realy amazing.
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

  3. #3
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Dapo,

    It's often easier to diagnose a problem if we can see the code that's causing it!
    George
    Home | Blog

  4. #4
    Join Date
    Aug 2007
    Posts
    18
    Sorry George, Here is the code

    DECLARE @OrderN CHAR(5)
    DECLARE @strSQL VARCHAR(4000)
    DECLARE @FileName VARCHAR(50)

    DECLARE OrderNum_Cursor CURSOR LOCAL FOR
    SELECT OrderNum
    FROM OrderView
    OPEN OrderNum_Cursor
    FETCH NEXT FROM OrderNum_Cursor INTO @OrderN

    WHILE @@FETCH_STATUS = 0
    BEGIN
    SET @FileName = '\\nitnwasvr01\ArchiveData\tbPrepaidData-' + @OrderN + '.txt'
    SET @strSQL='BCP "PrepaidHistory..tbprepaiddata" IN "'
    SET @strSQL=@strSQL + @FileName + '" -Snitnwasvr01 -c -T'
    EXEC master..xp_cmdshell @strSQL
    FETCH NEXT FROM OrderNum_Cursor INTO @OrderN
    CONTINUE
    END
    CLOSE OrderNum_Cursor
    DEALLOCATE OrderNum_Cursor
    DROP VIEW OrderView

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    can you put a
    Code:
    PRINT @strSQL
    and post the result please
    George
    Home | Blog

  6. #6
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    I suspect the error is in the data you are trying to bcp in from the files. Try to bcp in each of the files one at a time. When you hit the error, you can inspect the file and look for the offending datum (or data).

    -- This is all just a Figment of my Imagination --

  7. #7
    Join Date
    Aug 2007
    Posts
    18
    I have seen solution the the problem, my senior colleague change the table structure unknown to me, that is what causes the problem; below is the problem agin in case of another time:

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

  8. #8
    Join Date
    Jul 2003
    Location
    Amsterdam, Nederland
    Posts
    450

    Smile Lol

    Quote Originally Posted by Dapo
    I have seen solution the the problem, my senior colleague change the table structure unknown to me, that is what causes the problem
    Verry funny
    Rolling Over The Floor Laughing My Ass Off
    Greetz Marvels -^.^-
    Developments : VB4 Through .Net; Basic; DOS ; CNC ; Sinclair
    Databases : SQL Server Through 2005; Access 3 Through 2003 ; Oracle 8 & 9.i ;
    OS : Win 3.11 Through XP ; NortonComander ; DOS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •