Load CSV file into temptable

  • Hi Experts,

    can some one share script which loads data into temptable from csv file.?

  • You can learn how by going to this link.

    http://msdn.microsoft.com/en-us/library/ms141209(v=sql.100).aspx

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Thanks for the reply ron,

    I am expecting a script, not thru GUI

    Thanks again 🙂

  • Sqlism (10/15/2012)


    Thanks for the reply ron,

    I am expecting a script, not thru GUI

    Thanks again 🙂

    In the previous link note the following:

    You can also decide whether to save the package to SQL Server or to the file system. If you select to save the package, you must also specify a package protection level. For more information about package protection levels, see Setting the Protection Level of Packages.

    After the SQL Server Import and Export Wizard has created the package and copied the data, you can use the SSIS Designer to open and change the saved package.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Let me know if this helps..

    CSV FILE : Test.csv

    a,b

    1,A

    2,B

    3,C

    Then in the SSMS :

    create table #test(a int,b varchar)

    BULK INSERT #test1

    FROM 'C:\Test.csv'

    WITH

    (

    FIELDTERMINATOR =',',

    ROWTERMINATOR =' ',

    FIRSTROW = 2

    )

    Edit :ROWTERMINATOR = '\ n'

    This is one way to load from csv file to a table ...

    FIRSTROW is a check to filter out loading headers..

    ~ demonfox
    ___________________________________________________________________
    Wondering what I would do next , when I am done with this one :ermm:

  • Thanks for the script demonfox!

    It works for me.

    is there anyway, we can load data without declaring coulmn names and data types(data type is not the issue for me)

    My csv file has first row as column names

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

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