Geeks With Blogs

News
The Wrecking Bawl Destructuring query language, one keyword at a time.

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.

Posted on Tuesday, December 12, 2006 8:41 PM all tech stuff , SQL Server | Back to top


Comments on this post: casting SQL parameters

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Alex Bransky | Powered by: GeeksWithBlogs.net