May 4, 2020 at 1:40 pm
Use the TRY_CONVERT() or the TRY_CAST() function. They will return the value if it can convert/cast it, and will return NULL otherwise.
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
May 4, 2020 at 1:49 pm
what exactly are you trying to do?
Is it a one time conversion or a view that will be available for querying on the fly going forward?
and do you have sample data and code you used?
try_convert mentioned above has issues (same as isdate or isnumeric) and it not necessarily the best/correct option to use based on your data - or maybe it could be used in conjunction with further validation.
May 4, 2020 at 2:08 pm
what exactly are you trying to do?
Is it a one time conversion or a view that will be available for querying on the fly going forward?
and do you have sample data and code you used?
try_convert mentioned above has issues (same as isdate or isnumeric) and it not necessarily the best/correct option to use based on your data - or maybe it could be used in conjunction with further validation.
True DAT!!!
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply