0

I have a file which is fill of million of records and it looks like below:

20 Apr 2016 21:50:01,022      - username,,ResetGUI,Account,finished,8182819710127A590BAF3E5DFD9AE8B0.tomcat32,7

20 Apr 2016 21:50:01,516      - username,12345678,loadaccount,AccountAdmin,Starts,40A5D891F145C785CD03596AAD07209F.tomcat32,

I want to automate importing the data into a table.

I am not sure how it works?

Please advise!

2
  • use the sql server import export wizard Commented Sep 8, 2016 at 20:26
  • The last edit let the line breaks vanish... In your initial question, the date and time was in its own line. I'd start to replace the hyphen and the line breaks with a comma. After this action there should be a clean comma separated import... Commented Sep 8, 2016 at 20:29

2 Answers 2

1

If it is a one time data load you can use the SQL Server Import Export Wizard.

Right Click your DB in Management Studio -> Tasks -> Import Data

The wizard will guide you through selecting a database to import to, and a data source (other DB or flat file).

Sign up to request clarification or add additional context in comments.

Comments

1

Make sure you create csvtest table first. Make all cols as varchar(200) first to test import

If you can give me col names ill construct a create table script for u. I just need to know your table name. Col names and data types ( from source ).

If u plan to regurly import this file Process can be...

  1. If table exists truncate it.

  2. If table does not exist create one.

  3. Bulk load csv into new table

Anyways heres how to import into existing table from csv

BULK
INSERT CSVTest
FROM 'c:\csvtest.txt'
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)
GO

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.