Is data type checking possible in T-SQL

  • I created a stored procedure with a sql_variant parameter, but I'm having trouble thinking of a way to type-check it. The purpose of this variable is to pass a value for update/insert into a table (whose name is also passed in another parameter). It's easy enough to test for existance of the table and to check success of the filter (also passed in), but not type-checking the actual update/insert value. Thanks in advance!

  • I am hoping you have some knowledge of the datatypes that could be passed in. 

    Use IF statements with the various "IS" functions, (ISDATE, ISNUMERIC, ISNULL...) to test and you can pass the correct information from there. 

    If you need to check for things like char versus varchar, that becomes a bit trickier... 

    I wasn't born stupid - I had to study.

  • Gee, I guess that's sort of an obvious approach! Thanks!

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

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