RAISERROR datetime parameters, error in 2005, not 2000

  • The SQL 2005 documentation for RAISERROR parameters states:

    @local_variable

    Is a variable of any valid character data type that contains a string formatted in the same manner as msg_str. @local_variable must be char or varchar, or be able to be implicitly converted to these data types.

    However when trying to compile a stored procedure under 2005 that uses a datetime variable, an error occurs:

    Msg 2748...

    Cannot specify datetime data type (parameter 5) as a substitution parameter.

    Is this a bug or a feature?  What happened to the implicit conversion that works in SQL 2000 (and 7)?


    Have Fun!
    Ronzo

  • Have you tried the same in SQL2K?  It doesn't work for me...  Check BOL for "converting data types, precedence".  You will see that DATETIME is of higher precedence than *CHAR() meaning that *CHAR() will be converted to DATETIME but not the converse...

  • Interesting, because it works perfectly in SQL 2000 and SQL 7. 

    The only thing in my 2000 & 2005 BOL on data type precedence is in reference to combining different data types with an operator.  It would seem this would not apply since I'm not combining data types. 

    In any case, I thought it would be good to share this with the group and see if anyone had any info on this.  It would be a royal pain to have to find everywhere that raiserror is used and do explicit conversions to string just so our application can be migrated to 2005.


    Have Fun!
    Ronzo

Viewing 3 posts - 1 through 2 (of 2 total)

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