• ShuaibV (7/10/2013)


    Thank you Steven. This will be really helpful for me, i want to convert this to SQL FUNCTION and there is restriction we cant SET DATEFORMAT in the function. I have the view and wanted to use against a column in the view.

    Thanks

    I've tried to make a function out of this (preferably an inline tvf), but you can neither issue SET commands in a function nor use TRY/CATCH. If the DATEFORMAT is not an issue then that could be left out, but I haven't been able to figure out a way to do the necessary error-trapping within a function. Many methods for doing so have been suggested but I just haven't been able to get them to work in this case.

    This is simply a "trial-and-error" validation where the CONVERT is attempted and if it converts it's good and if not it fails, but there needs to be some mechanism for detecting and reporting a failure. If you or anyone else can turn this into an actual function I would be pleased. 🙂