Results 1 to 9 of 9
  1. #1
    Join Date
    Sep 2009
    Posts
    2

    Unanswered: Conversion failed when converting datetime from character string

    I have a web hosting with GoDaddy.
    But when I am trying to import txt file to GoDaddy SQL Server Database. It gives this error.

    "Error importing data from subscription_details.txt.
    Imported 0 rows.
    Errors:
    Conversion failed when converting datetime from character string. Changed database context to 'db1'."

    Any help would be appreciated, Thanks!

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    not enough information. somewhere where sql is expecteing a date, you are giving tit an invlaid value.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Sep 2009
    Posts
    2
    Hi Thrasymachus,

    At some extend you are right. Actually I have a column as datetime data type But when i export my table in flat file datetime column data convert into 2005-04-19 15:33:21.680000000 from 4/19/2005 3:33:21 PM.

    I am not able to understand why? Any help.

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    On the import I would import the file into a staging table with this column as a varchar and then I would have a sql script that converts this string to a date while in transit to its final destination. On the export I would convert the field as as varchar and use the format option of convert to get the desired result.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    For exporting datetime I always write views where I use convert(varchar(20), <datetime_field>, 120). Then I do a BCP from the view.
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

  6. #6
    Join Date
    Sep 2009
    Posts
    2

    avoid using timestamp


  7. #7
    Join Date
    Sep 2009
    Posts
    4
    Quote Originally Posted by jww_van
    same with me

  8. #8
    Join Date
    Oct 2009
    Posts
    1
    Not sure if you found your answer or not but here goes. I had a similar issue where I was importing a .csv file from MSSQL. 10 out of 1000 of my records had the full timestamp (or whatever the non rounded seconds field is).

    Your example: 2005-04-19 15:33:21.680000000

    I was able to import the csv by removing everything from the period to the end of the seconds.

    Ex: 2005-04-19 15:33:21

    Hope that help you and anyone else that finds this thread.

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    how are you importing?

    bcp?

    BULK INSERT?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

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