This repository contains a comprehensive setup for VIN decoding. The database is NHTSA's standalone database, from year 2022.
- Database Import: Begin by importing the
.bak
file into SQL Server Management Studio to set up the VIN Decode database. - Download the SQL database backup here .
- VIN Decoding: Use the SQL script to decode VINs. Follow the instructions to execute the script within SQL Server Management Studio.
- Data Processing: After decoding, use the provided Excel form to process and manage the output data.
- Product Information Catalog and Vehicle Listing (vPIC) Analytical User's Manual 2020: [https://crashstats.nhtsa.dot.gov/Api/Public/ViewPublication/813252]
- Data will always export as a 2 row x 6 column table. This allows sorting in the Excel form that has been provided.
- Columns A-F will populate: VIN, Year, Make, Model, Body Style, HEV/BEV Label (in this order)
- For version 3: If VIN does not decode clean (by NHTSA's definition) the cells will display
error
- For version 4: If error code #4, #8 or #11 is associated with the VIN decode process from the SQL query, the cells will display
error
.
- Download the database from this repository
- Download Microsoft SQL Server Management Studio
- Run the SQL script to create a new stored procedure
- Use notepad++ to copy 10,000 records at a time into Microsoft SQL Server Management Studio
- Syntax is below.
- Replace
[VIN]
and[YEAR]
with the VIN and the model year (if available) - Replace
[databaseName]
with the name of the database that was backed up.
- Replace
- Syntax is below.
- VINs should be able to be decoded at a minimum rate of 1000 VINs/minute.
- Process 10,000 VINs at a time to optimize speed. The excel sheet is set up to take a maximum of 10,000 records.
- Query results will need to be set so that the output is to a bar “ | “ delimited file. This prevents problems with columns that are comma delimited (the output text can contain commas which causes issues in the alignment of the data)
USE [databaseName]
GO
EXEC [dbo].[spVinDecode_v4] @v = [VIN], @year = [YEAR];
- After downloading the database from this repository, unzip the file and place in the C-drive
- Open SQL Server Management Studio. Right click
Databases
selectRestore Database...
- Under
Destination
name the database.
- Under
- Select
device
and click...
then clickadd
- Locate the
.bak
file, select it, clickok
- Right click on the database, select New Query
- Paste the SQL Code into the Query tab that opens
- Select execute
- The stored procedure is now available for decoding.
SQL script to create a new stored procedure is linked below. This needs to be run in Microsoft SQL Server management Studio to create a new stored procedure that processes VINs properly. Use with the 2022 database located in this repository (not compatible with the newer versions from NHTSA).
- spVinDecode_v3 is the version with the most strict handling for error messages
- spVinDecode_v4 is a version that only produces an error in the decode results for codes #4, #11, and #8.