casting SQL parameters

A coworker and I discovered the other day that we got an error when we tried using CAST on a parameter in the same line as the procedure call.  For example:

EXEC [procname] @param1, CAST(@param2 AS DATETIME)

result: Invalid syntax near 'cast'.

That statement didn't work till we separated it into two lines, like so:

SET @param2 = CAST(@stringdatevar AS DATETIME)

EXEC [procname] @param1, @param2

I haven't been able to google up any proof that the first call should cause an error, so it would be greatly appreciated if somebody could drop me a link.

Print | posted on Tuesday, December 12, 2006 8:41 PM

Comments on this post

No comments posted yet.

Your comment:

 (will show your gravatar)
 
Please add 5 and 7 and type the answer here: