O'Reilly logo

SQL Server 2012 with PowerShell V3 Cookbook by Donabel Santos

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Performing bulk import using BULK INSERT

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

Getting ready

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

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

To create the table that we need for this exercise, open up 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required