data

  • I have a column defined as

    col1  datetime2 default current_timestamp NULL
    Don't ask why.  I'm tried to import a date into it using a CSV file.
    here is an example:
    2011-12-14 12:09:21.472
    Of course, the column is not accepting my handiwork.   I'm thinking this is may be because the current_timestamp default wants the current date and time.
    But defaults can be overridden, so maybe I'm out to lunch again.  Advice is appreciated.    Thanks.

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

  • Hm,
    is there any kind of error-text?
    Kind regards,
    Andreas

  • Works for me:
    CREATE TABLE #temp (col1 datetime2 default current_timestamp NULL)
    INSERT INTO #temp(col1) SELECT '2011-12-14 12:09:21.472'
    SELECT * FROM #temp
    GO
    DROP TABLE #temp

    Can you supply a line or two of the csv?

  • Thanks.  I'll do some research

    When the snows fall and the white winds blow,The lone wolf dies but the pack survives.

    Once you've accepted your flaws, no one can use them against you.

  • Perhaps on your system datetime2 defaults to datetime2(2)  or (1)
    SELECT Cast(SysDateTime() AS date) Dt;

    SELECT Cast(SysDateTime() AS datetime) Dt;

    SELECT Cast(SysDateTime() AS datetime2(1)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(2)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(3)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(4)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(5)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(6)) Dt;

    SELECT Cast(SysDateTime() AS datetime2(7)) Dt;

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply