SQL Server stored procedure to import Excel file into SQL Server table

I am using SQL Server 2012.
I need to import an Excel File and a CSV file into SQL Server tables.

I  Excel file is "C:\Data\Cust_Data.xlsx". The CSV is "C:\Data\Cust_Data.CSV".
The name of the SQL Server table where both CSV and Excel file should be uploaded is "Customers".
The database is "MainData". The CSV, Excel file and SQL Server table have the same fields.
Could some one please write a Stored procedure in SQL Server to import the Excel file into the SQL Server table.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This can be done in SQL directly but SSIS is much better to import files.  A link to the basics is here:
Vitor MontalvãoMSSQL Senior EngineerCommented:
Here's almost everything you need to know:
USE MainData

    FROM 'C:\Data\Cust_Data.CSV'
    FIRSTROW = 2, -- remove this line if there is no leading row
    FIELDTERMINATOR = ',',  --field delimiter (depending on the region, some CSV uses ';')
    ROWTERMINATOR = '\n'   --row delimiter

Open in new window

Do the same for other files/tables. If you want to put it in a stored procedure, then it's very easy. Just learn about the CREATE PROCEDURE command.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vsuripeddiAuthor Commented:
I accept this solution.
Vitor MontalvãoMSSQL Senior EngineerCommented:
Recommendation to close this question by accepting the above comments as solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.