Home Forums SQL Server 2005 T-SQL (SS2K5) Conversion failed when converting datetime from character string - Error.... RE: Conversion failed when converting datetime from character string - Error....

  • DP-721271 (7/6/2010)


    ...

    /* Tried the following as well*/

    IF @vchtstsirdt IS NULL

    SET @vchtstsirdt = CONVERT(datetime, ISNULL(@vchtstsirdt,''))

    Else

    SET @vchtstsirdt = CONVERT(datetime, @vchtstsirdt)

    ...

    That is also code noodles, but with different result.

    NULL values will be converted to 1 Jan 1900

    🙂

    And there is very simple explanation for the error you getting:

    Conversion failes due to some of values yuo have cannot be converted to datetime 😀

    Looking your code I also suspect that you don't really need a cursor :w00t:.

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]