Monday, March 5, 2012

Storing Excel file into SQL:


Storing Excel file into SQL:

Step 1: Create a Excel file and add Columns.
Step 2: Save as the Excel file in CSV format.
Step 3: Create a Table .Table fields are match with Excel Columns.

For ex:
Excel Having the following Columns
Sno
Name
City
Pincode
SQL Must Have the following fields
Sno,Name,City,Pincode
 
Step 4: Run this query in SQL.
Syntax:

BULK
INSERT table name
FROM 'csv file Path’
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

Example:

BULK
INSERT TestTableName
FROM ' C:\Users\bharathi\Desktop\TextExcelFile.CSV’
WITH
(
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n'
)

No comments:

Post a Comment