How to import data from .csv file into a table in sql server using bcp in/out

  • Hi experts,

    I have a .csv file from which i have to do bcp out and bcp in, in command prompt and store the data into a table called temp.

    How do i get the data into the table from a .csv file?

    I have created the datafile and format file for temp.

    How to get the values from .csv file and do bcp in to load it into the table 'temp'?

    Please help me

    Thanks in advance

  • I personally use a Bulk Insert statement:

    BULK INSERT [tablename]

    from '[Full File Path]'

    WITH ( BATCHSIZE = 100000, FIELDTERMINATOR = ',' )

  • Thanks for ur reply

    but i wanted to import using bcp instead of bulk insert...

  • What is the reasoning on using BCP?

    But if you have the format file and the data in a csv format, all you need to do is build a BCP command using this link as a reference (http://msdn.microsoft.com/en-us/library/ms162802.aspx) with the right switches to import the data.

  • arthi.anan (10/30/2012)


    Thanks for ur reply

    but i wanted to import using bcp instead of bulk insert...

    There may, of course, be specific reasons for your choice though do bear in mind that Bulk Insert is typically faster and neater especially if used from within a Stored Procedure.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply