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....

  • ...

    IF @vchtstsaddt IS NULL

    BEGIN

    SET @vchtstsaddt = NULL

    END

    Else

    SET @vchtstsaddt = CONVERT(datetime, @vchtstsaddt)

    ...

    This makes little or no sense. If the variable already is null, why set it to null?

    On the other hand, each of the variables is declared as a nvarchar(30) data type. Most likely, one of those does not actually contain a value that can be converted to a datetime value. I would check the actual contents of those values to see if you have bogus values. In any event, you're then assigning the datetime converted value back to the nvarchar variable. What is then done with these values?

    Rob Schripsema
    Propack, Inc.