Google libphonenumber
SQL Server handoff
SQL Server handoff · version 9.0.39

Google
libphonenumber

A pinned Google lookup dataset, a repeatable SQL Server installer, an exact-content validator, and the original downloaded files in one portable package.

215calling codes
254region rows
32,497NANP prefixes

What is installed

dbo.PhoneCountryRegion maps international calling codes to all regions Google lists for each code. Shared codes have multiple rows; 001 represents a non-geographic service.

dbo.PhonePrefixGeography contains English NANP prefix labels. Use the longest matching prefix for the most specific available description.

dbo.PhoneSourceManifest records the pinned tag, commit, counts, and import hashes.

What the labels mean

Google’s place text is a descriptive phone-prefix lookup. It does not establish whether a number is active, where its current user lives, or a current area-code assignment status.

For administrative NPA status use NANPA reports. For authoritative E.164 assignments use the ITU list.

This package contains Google data. NANPA and ITU data are linked for reference and are not loaded into these tables.

Install on your SQL Server

  1. Download and extract the complete ZIP.
  2. Open PowerShell 7 or Windows PowerShell 5.1 on a computer that can reach the target SQL Server.
  3. Use a login with permission to create the database and tables. Enter the target when prompted.
  4. Keep the package for later validation and repeat installs.
$target = Read-Host 'Target SQL Server or instance'
& .\Install-PhoneNumberReference.ps1 -SqlInstance $target

The installer creates the database and three tables, replaces the imported rows in a transaction, then runs validation. It can be run again.

Target options

Server: supplied at run time
Default database: PhoneNumberReference
Default authentication: Windows integrated
Source: Google libphonenumber v9.0.39

Use -Database to choose a database name, or -SqlCredential (Get-Credential) for SQL authentication. Connections are encrypted. Use -TrustServerCertificate only when you have confirmed the target and its certificate is not trusted by the client. Python is needed only to regenerate the CSVs.

The installer replaces rows in its three dedicated tables. Review that behavior before using it against a database where those table names already exist.

Find the place label

Connect to the database selected during installation. Supply digits only, including the international calling code. Longer matches take precedence over broad prefixes.

DECLARE @Digits varchar(20) = '13125551212';
SELECT TOP (1) FullPrefix, LocationText
FROM dbo.PhonePrefixGeography
WHERE Locale = 'en'
  AND LEFT(@Digits, LEN(FullPrefix)) = FullPrefix
ORDER BY LEN(FullPrefix) DESC;

Find the regions for a code

One calling code can serve several regions. Query all rows, then use IsPrimaryRegion where a display needs one default.

SELECT CallingCode, RegionCode,
       IsPrimaryRegion
FROM dbo.PhoneCountryRegion
WHERE CallingCode = '1'
ORDER BY IsPrimaryRegion DESC,
         RegionCode;

The package includes additional queries in Examples.sql.

Run the validator

& .\Test-PhoneNumberReference.ps1 -SqlInstance $target

Use the same database and authentication options as the installer. The validator checks SHA-256 for the downloaded originals and generated CSVs, compares every CSV row with SQL, confirms stored version and commit metadata, and tests a longest-prefix result.

Expected package counts: 254 country-region rows and 32,497 prefix rows.

Accuracy boundary

The validator establishes that SQL matches this captured Google release. It cannot determine whether Google’s labels reflect today’s number assignments or a subscriber’s physical location.

Google’s tagged repository is the source. The package pins commit 670015c8aec4c3a84769c664f194677201236b43 and includes its Apache 2.0 license.

Complete handoff

The ZIP contains exactly the 14 files inventoried below. Extract the entire archive before running the installer so the scripts, data, manifest, and original source files remain together.

Download complete package ↓

Captured from Google libphonenumber v9.0.39. Keep the license with redistributed files.

Package inventory · 14 files

These are the exact relative paths included in the downloaded ZIP.

  • Install-PhoneNumberReference.ps1Creates the database objects, imports the CSV data, and runs validation.
  • Test-PhoneNumberReference.ps1Checks file hashes, row contents, metadata, and a longest-prefix lookup.
  • schema.sqlDefines the three SQL Server tables, indexes, view, function, and stored procedure.
  • Examples.sqlProvides sample country-code and longest-prefix queries.
  • country_regions.csvGenerated calling-code-to-region import data.
  • nanp_geography.csvGenerated NANP prefix-to-location import data.
  • manifest.jsonRecords the source version, commit, row counts, and SHA-256 hashes.
  • prepare_data.pyRebuilds the CSV files and manifest from the pinned Google sources.
  • README.mdPortable setup, authentication, validation, and usage instructions.
  • Guide.htmlOffline copy of this installation and usage guide.
  • source/1.txtOriginal English NANP geocoding data from Google.
  • source/CountryCodeToRegionCodeMap.javaOriginal Google calling-code-to-region mapping.
  • source/release_notes.txtOriginal libphonenumber release history.
  • source/LICENSEApache License 2.0 for the included Google source material.