Bulk Export of Serial Numbers to SQL Server

DeployLX provides an extensive API for generating serial numbers on-demand for integration into an e-commerce solution. However sometimes it's just easier to generate a batch of serial numbers to store in the database. This article describes how to generate a batch of serials and import them into SQL Server. 

On This Page

Generate your serial numbers through the DeployLX Manager.

  1. Select the target license from the License Editions.
  2. Select Generate Code | Generate Serial Number.
  3. Set Number of serials to generate to the desired number.
  4. Select Plain output.
  5. Select Generate. The serial numbers are generated and shown.
  6. Select Save and select a location to save the serial numbers to.

Importing Into SQL Server

There are two ways to import the serials into SQL server. If you have a well structured database and use some sort of ORM tool, you'll want to create a script that parses the Serials.txt file and inserts new objects into the database.

Importing into database with an ORM script 

Using serials = New StreamReader("Path to Serials.txt")
    Do While Not serials.EndOfStream
        Dim serial = serials.ReadLine()
        If serial Is Nothing OrElse serial.Length = 0 Then
            Continue Do
        End If

        Dim serialEntity = New SerialNumberEntity() With {.SerialNumber = serial}
End Using
using( var serials = new StreamReader( "Path to Serials.txt" ) )
    while( ! serials.EndOfStream )
        var serial = serials.ReadLine();
        if( serial == null || serial.Length == 0 ) 
        var serialEntity = new SerialNumberEntity() { SerialNumber = serial };

Importing with SQL Server Import and Export Wizard

The other option is to import directly into SQL Server using the Import and Export Wizard. This sample will demonstrate importing into a table defined as

CREATE TABLE AvailableSerialNumbers (
    Value nvarchar(100) NOT NULL,
    IssuedToID int NULL,
  1. Open SQL Server Management Studio.
  2. Select View | Object Explorer.
  3. Right-click on the target database and select Tasks | Import Data.
  4. Configure the Data Source.

    1. For Data source select Flat File Source.
    2. Select Browse... and select the location of the Serials.txt file generated earlier.
    3. Select Next
  5. The Destination should be set correctly. Update as needed, then select Next.
  6. Change the Destination to AvailableSerialNumbers.
  7. Select Edit Mappings.
  8. Change the Destination to Value.
  9. Select OK.
  10. Select Next, Next, Finish to run the import.

Congratulations. The serial numbers have been imported.

Published : Jan 05, 2011
Updated : Jan 04, 2012
Views : 3646
  • licensing
  • deploylx

Applies To