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

Google Library
Phone Number

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

215calling codes
246region names
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.PhoneRegionName maps those region identifiers to 246 current English display names from Unicode CLDR 48.2, with a package-specific label for 001.

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

dbo.PhoneSourceManifest records the pinned versions, dates, 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.

The calling-code and prefix data comes from Google. Region display names come from Unicode CLDR. 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

Copy-ready command

Replace <server-or-instance> with the destination SQL Server name. Keep this command on one line:

.\Install-PhoneNumberReference.ps1 -SqlInstance '<server-or-instance>' -Database 'PhoneNumberReference' -TrustServerCertificate

The installer creates the database and four tables, replaces the imported rows in a transaction, then runs validation. It can be run again. Use -TrustServerCertificate only when the destination requires it.

Target options

Server: supplied at run time
Default database: PhoneNumberReference
Default authentication: Windows integrated
Sources: Google libphonenumber v9.0.39 and Unicode CLDR 48.2

Use -Database to choose a database name, or -SqlCredential (Get-Credential) for SQL authentication. Connections are encrypted. -TrustServerCertificate is a switch and takes no value. If you split a command across lines, each PowerShell backtick must be the final character on its line; do not use a backslash.

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

Upgrade an existing installation

Download and extract the newest complete ZIP into a new folder. Run the installer against the same SQL Server and database used by the current installation:

$target = Read-Host 'Target SQL Server or instance'
& .\Install-PhoneNumberReference.ps1 `
    -SqlInstance $target `
    -Database 'PhoneNumberReference' `
    -TrustServerCertificate

Keep the final line only when the target certificate requires it. -TrustServerCertificate is a PowerShell switch, so do not write -TrustServerCertificate true.

The upgrade keeps the database, creates missing objects such as dbo.PhoneRegionName, adds newer manifest columns, replaces the package-owned table rows in a transaction, and runs the validator automatically. Refresh the Tables folder in your SQL editor after the command reports PASS.

SELECT c.CallingCode,
       c.RegionCode,
       n.RegionName,
       c.IsPrimaryRegion
FROM dbo.PhoneCountryRegion AS c
JOIN dbo.PhoneRegionName AS n
  ON n.RegionCode = c.RegionCode
 AND n.Locale = 'en'
WHERE c.CallingCode = '44'
ORDER BY c.IsPrimaryRegion DESC,
         c.RegionCode;

The primary row should be GB — United Kingdom. If the existing installation uses another database name, supply that exact name with -Database.

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.

Get current country names

dbo.PhoneRegionName is installed and populated with 246 current English display names from Unicode CLDR 48.2. Join it to dbo.PhoneCountryRegion by RegionCode and Locale.

SELECT c.CallingCode,
       c.RegionCode,
       n.RegionName,
       c.IsPrimaryRegion
FROM dbo.PhoneCountryRegion AS c
JOIN dbo.PhoneRegionName AS n
  ON n.RegionCode = c.RegionCode
 AND n.Locale = 'en'
WHERE c.CallingCode = '44'
ORDER BY c.IsPrimaryRegion DESC,
         c.RegionCode;

Calling code 44 returns region code GB with the name United Kingdom. Shared calling codes can return several named regions.

The display names are captured from Unicode CLDR 48.2. The table stores the source and as-of date with every row. Review later CLDR releases when you need to refresh names independently from the pinned Google phone metadata.

001 is handled explicitly. In libphonenumber it represents a non-geographic service, so this package stores “Non-geographic service” instead of CLDR’s global “world” label.

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 versions and dates, and tests both a longest-prefix result and calling code 44 resolving to United Kingdom.

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

Accuracy boundary

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

Google’s tagged repository supplies the calling-code and prefix data. Unicode CLDR 48.2 supplies the English display names.

Complete handoff

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

Download complete package ↓

Phone metadata is captured from Google libphonenumber v9.0.39. English region names are captured from Unicode CLDR 48.2. Keep both licenses with redistributed files.

Package inventory · 17 files

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

  • Install-PhoneNumberReference.ps1Creates the database objects, imports all CSV data, and runs validation.
  • Test-PhoneNumberReference.ps1Checks hashes, every imported row, provenance, and representative lookups.
  • schema.sqlDefines the four SQL Server tables and their keys and constraints.
  • Examples.sqlProvides calling-code, country-name, and longest-prefix queries.
  • country_regions.csvGenerated calling-code-to-region import data.
  • region_names.csvGenerated English region-name import data.
  • nanp_geography.csvGenerated NANP prefix-to-location import data.
  • manifest.jsonRecords source versions, dates, counts, and SHA-256 hashes.
  • prepare_data.pyRebuilds all CSV files and the manifest from the captured 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 material.
  • source/cldr-territories-en.jsonUnicode CLDR 48.2 English territory names.
  • source/CLDR-LICENSEUnicode license for the included CLDR material.