Tuesday, February 14, 2012

Loading data from excel file to table in SQL Server

Create a table structure with appropriate datatypes according to your data in a file.
Save file in .csv format. Use below script to load data.
Note: You may get errors if you use in appropriate datatypes or size.

BULK INSERT EMP -- Table Name
FROM ‘C:\’ -- File Path
WITH ( FIELDTERMINATOR = ‘,’,
ROWTERMINATOR = ‘\n’
)

No comments:

Post a Comment