Google Library Phone Number
SQL Server handoff
SQL Server handoff · version 9.0.39

Google Library
Phone Number

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 regions for one calling code

International calling codes are stored in dbo.PhoneCountryRegion. One calling code can serve several regions, so query all matching rows.

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

This returns the region or regions associated with calling code 44.

List every international calling code

The captured Google data contains 215 calling codes and 254 calling-code/region rows. Shared codes appear once for each associated region.

SELECT CallingCode,
       RegionCode,
       IsPrimaryRegion
FROM dbo.PhoneCountryRegion
ORDER BY TRY_CONVERT(int, CallingCode),
         IsPrimaryRegion DESC,
         RegionCode;

IsPrimaryRegion identifies the first region Google assigns to a shared calling code. The package includes additional queries in Examples.sql.

Optional: add current country names

The installed Google data provides stable region identifiers such as GB, not country display names. If you need names as they exist today, load them into a separate, refreshable table and join on RegionCode. This optional table is not installed by the package.

CREATE TABLE dbo.PhoneRegionName
(
    RegionCode     varchar(3)    NOT NULL,
    Locale         varchar(10)   NOT NULL,
    RegionName     nvarchar(200) NOT NULL,
    SourceName     varchar(100)  NOT NULL,
    SourceAsOfDate date          NOT NULL,
    CONSTRAINT PK_PhoneRegionName
        PRIMARY KEY (RegionCode, Locale)
);

Use the current UN M49 Country or Area list for UN short names and ISO alpha-2 identifiers. For localized, interface-friendly names, use Unicode CLDR territory names. ISO explains how the codes are maintained in its ISO 3166 overview.

SELECT c.CallingCode,
       c.RegionCode,
       n.RegionName,
       c.IsPrimaryRegion
FROM dbo.PhoneCountryRegion AS c
LEFT JOIN dbo.PhoneRegionName AS n
  ON n.RegionCode = c.RegionCode
 AND n.Locale = 'en'
WHERE c.CallingCode = '44';
Handle 001 explicitly. In libphonenumber it represents a non-geographic service; UN M49 uses 001 for World. Store a package-specific label such as “Non-geographic service” instead of joining it to the UN World entry.

Record the source and as-of date with every load. Refresh country names independently from the pinned libphonenumber release because names and telephone assignments change on different schedules.

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 and their keys and constraints.
  • 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.