Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

An excel file having 130 records with column names
emp_id, emp_name, emp_address, connection_model.

I need to insert these all records into a table using sql like below query
SQL
insert into emp values(&emp_id,'&emp_name','&emp_address','&connection_mocel');

and entering values manuallly ,but it is taking much time to complete.

Is there any way to get excel records into the table ?

Help me to complete this task.

Thanks in advance.
Posted
v3
Comments
The query is not looking like a valid one.
Is it working ?

I have a tip on this. You can try. Just you need to save your excel file as .csv format. Then follow the steps of the tip

Insert into database from CSV file[^]

Happy Coding :)
 
Share this answer
 
You can use CONCATENATE[^] function to build the insert statement in excel.
You can take the text "insert into emp values(" in one column in excel sheet and then concatenate the column values and build the insert statement.
Refer
How to Concatenate Text in Microsoft Excel[^]
 
Share this answer
 
v2
You can use SQL Server Import Export wizard to do this task. Have a look:
http://www.66pacific.com/sql_server_import_from_excel.aspx[^]
 
Share this answer
 
Save the spreadsheet as a tab-delimited textfile.
Then using a statement like this, add the data from it to the table ([tblExcelTdData130]):
BULK INSERT [tblExcelTdData130] FROM 'C:\users\cp\sc\datafile(td).txt'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900