Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL
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
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 6-Mar-13 20:17pm
v3
Comments
Tadit Dash at 7-Mar-13 1:25am
   
The query is not looking like a valid one.
Is it working ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 Smile | :)
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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[^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

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'
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 277
1 Maciej Los 210
2 BillWoodruff 205
3 Jochen Arndt 180
4 DamithSL 165
0 OriginalGriff 5,130
1 DamithSL 4,157
2 Maciej Los 3,670
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,821


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100