Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

1 - Create a data-format file, name it with the file extension ".fmt", e.g. DB3DB5.FMT. Copy the content below to the file:

Code Block
languagesql
12.0
79
1 SQLCHAR 0 1 "\"" 0 first_double_quote  Latin1_General_CI_AI
2 SQLCHAR 0 20 "\",\"" 5 ip_from ""
3 SQLCHAR 0 20 "\",\"" 6 ip_to ""
4 SQLCHAR 0 255 "\",\"" 3 country_code Latin1_General_CI_AI
5 SQLCHAR 0 255 "\",\"" 4 country_name Latin1_General_CI_AI
6 SQLCHAR 0 255 "\",\"" 7 region_name Latin1_General_CI_AI
7 SQLCHAR 0 255 "\",\r\n"" 2 city_name Latin1_General_CI_AI
8 SQLCHAR 0 20 "\",\"" 8 latitude ""
9 SQLCHAR 0 20 "\"\r\n" 9 longitude ""
  

*Make sure that there is a carriage return after the last row.

...

Code Block
languagesql
BULK INSERT [dualshield_database_name].[dbo].[ip2location_db3]
    FROM 'FILE-PATH-TO\IP2LOCATION-LITE-DB3DB5.CSV'
    WITH
    (
        FORMATFILE = 'FILE-PATH-TO\DB3DB5.FMT'
    )
GO

* replace "dualshield_database_name" with the name of the DualShield database. By default, it is "DualShield"

* replace "FILE-PATH-TO" with the actual file path where the downloaded file is saved, e.g. "c:\downloads"

* the name of the table in the database is called "ip2location_db3", although the import file is called "db5.csv"

Please note that it can take about 30 minutes to import the data.

...