Matheus, SQL SERVER does not have a function for validation of CPF or CNPJ , these types of numbers are Brazilian standards and are not applied to other countries, such a function would have no use for many users of that database.
You have the option to throw the exception through BEGIN TRY END TRY or use the RAISERROR to return an error message.
The ideal in this case is that you treat your client-side validation (EX, JavaScript) and application (EX, C #, JAVA), do not use the database for this type of validation, this has a cost of processing back and forth to the bank, when your application could easily validate.