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

How to query information from a zip code in SQL Server

Views: 4.426 views
Reading Time: 2 minutes

Hello people,
Good day.

In this quick post, I will once again demonstrate the use of OLE Automation procedures to consume information on the web and bring it to our SQL Server database so that we can work with this information as needed. If you want to use the Bemean API, which returns data in JSON format, see more in the post. SQL Server 2016 - How to Query Zip Code Information Using the Bemean API and JSON_VALUE Function

This time, I'll show you how to query city, state, neighborhood, add-on, and IBGE code information from an informed zip code.

Querying CEP Data

To perform this operation, I will use the great service of the page to see the zip code information.

I will filter the input zip code so that it contains only numbers. After that, we make a GET request on the viacep URL and then handle the return via XQuery.

After we create the function, we will use it to test the result:
Search ZIP Code

That's it!
Thank you and see you next time!