May 17, 2006 at 9:51 am
The SQL 2005 documentation for RAISERROR parameters states:
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)?
May 18, 2006 at 6:37 am
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...
May 22, 2006 at 9:53 am
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.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply