Performing bulk import using BULK INSERT

This recipe will walk through how to import contents of a CSV file to SQL Server using PowerShell and BULK INSERT.

Getting ready

To do a test import, we need to create a Person table similar to the Person.Person table from the AdventureWorks2014 database, with some slight modifications.

We will create this in the Test schema; we will remove some of the constraints and keep this table as simple and independent as we can.

To create the table we need for this exercise, open up SQL Server Management Studio and run the following code:

CREATE SCHEMA [Test] GO CREATE TABLE [Test].[Person]( [BusinessEntityID] [int] NOT NULL PRIMARY KEY, [PersonType] [nchar](2) NOT NULL, [NameStyle] [dbo].[NameStyle] NOT NULL, [Title] ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.