Click here to Skip to main content
11,584,208 members (54,058 online)
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 19: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 390
1 Sergey Alexandrovich Kryukov 334
2 Dave Kreskowiak 240
3 Richard Deeming 220
4 virusstorm 194
0 OriginalGriff 1,663
1 Sergey Alexandrovich Kryukov 1,229
2 Abhinav S 701
3 Dave Kreskowiak 667
4 Suvendu Shekhar Giri 568


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 7 Mar 2013
Copyright © CodeProject, 1999-2015
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