Importing Large Text File with bcp Command



--Run from command line to import one million records and skip the header row
bcp [myDB].dbo.[myTableExistingInDB] in "C:\temp\myFileTest.txt" -c -T -F 2 -S "myServer\myInstanceName"

Or

--Run from SSMS:

DECLARE @sql VARCHAR(4000) 
SET @sql='bcp  myDB.dbo.ATable in "C:\temp\test3.txt" -c -T -F 2 -S"'+ @@servername
exec master..xp_cmdshell @sql

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s