Click on the banner to learn about and purchase my database training on Azure

How to validate state registration using T-SQL function in SQL Server

Views: 1.533 views
Reading Time: 14 minutes

Good day.

Today I will make a quick post for you and it is very useful in daily life, especially for those who create integration routines with Sefaz, Revenue and other government agencies and need a routine to validate the state registration for all states of Brazil , or even for those who want to have this field in their system with validated and intact data.

To perform this check, I found in a blog a very complete function, developed by Rodrigo Ebner, which fulfills this need well.

Usage examples

Let's see how we use this function to validate state registration:

Function source code

Now that we've seen how to use this User Defined Function (UDF), let's take a look at your source code to understand how numbers are validated and you can create this function in your environment as well:

View source

And that's it guys,
To the next.