I need to write a UDF that would try to cast a varchar to a bigint and return either that bigint or zero if failed. The problem is – I can’t find a way to silence casting error when the string is not a valid number. TRY CATCH doesnt work inside functions and I don’t know what else to do.
Share
Try this: