The Bulk Insert in SQL Server (shortly called as BCP) will be very helpful to quickly transfer large amount of data from Text File or csv file to SQL Server Table or Views.
BULK INSERT in SQL Server example
In this example We will show you, How to transfer the data present in the text file to SQL table. We have a flat file called GEOGRAPHY.txt contains 1000000 Rows. Our task is to insert all the rows present in this text file using Bulk Insert statement.
Our SQL Server table is:
In order to transfer the data present in the text file or Csv file to SQL table, Please open your SQL Server management Studio and write the following query
BULK INSERT [SQL Server Tutorials].[dbo].[DimGeography]
FROM 'F:\MS BI\FILE EXAMPLES\Geography.txt'
DATAFILETYPE = 'char',
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
TIP: If you want to send the data in multiple batches then use ROWS_PER_BATCH
Let us open the SQL Server Management Studio and check the destination table, whether we successfully copied the data from text file to SQL server or not.
Thank You for Visiting Our Blog