In this recipe, we will import some pipe-delimited files into an existing table in our SQL Server instance.
In this recipe, we will create an empty table called SampleText
in your database instance:
CREATE TABLE [dbo].[SampleText] ( [CustomerID] [varchar](20) NOT NULL PRIMARY KEY, [LastName] [varchar](50) NOT NULL, [FirstName] [varchar](50) NOT NULL, [Phone] [char](20) NOT NULL, [AddressLine] [varchar](50) NULL, [City] [varchar](20) NULL, [State] [char](5) NULL, [Country] [varchar](10) NOT NULL )
We will import records in the file called Customers.txt
into the SampleText
table. The text file is a pipe-delimited text file that contains values for all the columns in the SampleText
table: