How to validate state registration for all states using C # (CSharp) and SQL Server CLR

Views: 0
Reading Time: 16 minutes

Hello people,
Good night!

In this post, I will bring again a function for state registration validation of all states of Brazil, as I had already shown in my post How to validate state registration using T-SQL function in SQL Server, but this time, I bring you the function written in C #, to be used in your CLR projects in SQL Server database or even in C # development projects yourself, having nothing to do with CLR or SQL Server and without the need importing external libraries.

Validation of state registration is very important for invoice issuers, financiers, banks and commerce in general and this information must be without valid and complete, according to Sefaz and Sintegra regulations.

I found it cool to share this solution in C # on CLR, because its performance is far superior to the T-SQL function and the code can be more organized and easy to understand.

Function Usage Examples


SQL Server - CLR Validate State Registration csharp .net

Validation function source code

Now that I've shown how easy it is to validate state registration for any state in Brazil, I will demonstrate the source code, written in C #, ready to copy and paste into your CLR project and use from SQL Server queries:

View function source code

If you still don't know what CLR is and how to use functions written in C # (.NET) by the SQL Server database, learn more by visiting my post. Introduction to SQL Common Language Runtime (CLR) in SQL Server

That's it folks!
Until the next post!