Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,155,505 members, 7,826,907 topics. Date: Monday, 13 May 2024 at 10:39 PM

Excel To Microsoft Sql Server - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Excel To Microsoft Sql Server (2462 Views)

Vb.net Code To Display Image In Picturebox From Sql Server / Changing From Vb6 To Microsoft Visual Basic 2005 / Oracle Vs Sql Server (2) (3) (4)

(1) (Reply) (Go Down)

Excel To Microsoft Sql Server by mj(m): 12:29am On Jan 09, 2012
Pls I need help in sending data from excel sheet to sql server. Thanks.
Re: Excel To Microsoft Sql Server by mj(m): 8:48pm On Jan 09, 2012
Pls, can any1 help me on dz? I rily need help in sending data from d cells in excel to sql database using VBA. Thanks.
Re: Excel To Microsoft Sql Server by dellnet: 1:31pm On Jan 10, 2012
A simple example assuming you have 10 rows and to get the value of the first column in each. Change the connection string and in Cnxn.Execute to appropriate sql query to execute and see it in action.

This is a vague example to get you started, should be "ok" for a small excel file.

Private Sub Workbook_Open()

Dim Cnxn, val
Cnxn = CreateObject("ADODB.Connection"wink
Cnxn.ConnectionString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;" 'change to valid cs
Cnxn.Open

Dim i As Integer
For i = 0 To 10
val = Worksheets(1).Cells(i, 1).Value '10 rows first column
Cnxn.Execute "INSERT INTO table VALUES("& val & "wink", 0, 1 'change sql query to appropiate query.
Next
Cnxn.Close
End Sub
Re: Excel To Microsoft Sql Server by mj(m): 4:24pm On Jan 12, 2012
thanks, let me work on it, I'll reach you back. thanks once again.
Re: Excel To Microsoft Sql Server by mj(m): 1:41pm On Jan 13, 2012
@Dell_net, thanks very much, pls I'm havin problem inserting a variable dt contains alphabets into the sql, , let's say a string. Thanks.
Re: Excel To Microsoft Sql Server by dellnet: 9:59am On Jan 14, 2012
mj:

pls I'm havin problem inserting a variable dt contains alphabets into the sql

I don't really understand what you mean.
Re: Excel To Microsoft Sql Server by Kobojunkie: 8:29am On Jan 15, 2012
@Poster, http://support.microsoft.com/kb/321686

Google is your friend
Re: Excel To Microsoft Sql Server by besito: 10:24am On Jan 18, 2012
Pls where can i get sql software?
Re: Excel To Microsoft Sql Server by abacus(m): 6:24pm On Jan 19, 2012
Hi


1. Using SSIS, SSIS is service you can install along with your sql server database engine. Having done that, see link below:

http://www.codeproject.com/KB/database/Import-Excel-SISS.aspx

[size=20pt]OR[/size]

2. Using Import Wizard  in your SSMS, see link below:

http://www.rodolforodarte.com/2010/03/importing-data-into-sql-server-using-the-import-export-wizard/

[size=20pt]OR[/size]

3. Using T-SQL code, This is also interesting

http://pratchev..com/2007/10/importing-excel-data-into-sql-server.html

    SELECT * INTO BenchmarkSurvey

    FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',

    'Data Source=C:\Benchmark Survey\Received\Survey1009.xls;

     Extended Properties="Excel 8.0;IMEX=1"'), [Sheet1$];


http://support.microsoft.com/kb/321686
http://www.siusic.com/wphchen/how-to-solve-problem-that-excel-data-imported-into-sql-server-via-dts-became-null-108.html

Hope those will help you out.

#rtfm

1 Like

(1) (Reply)

Running Software From A Server To A Local Pc / CRUDCAST: Two Nigerian Programmers Chat About Technology / Google Hacking

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.