How i can copy this excel table to a temporal table in SQLserver.

melvincast

New Member
Joined
Jun 9, 2015
Messages
3
i got this code , i want to copy this table to a temporal table in SQL server, and if the temporal table exist, i want to drop ip and create again, some help please, This connection code is usefull.

[TABLE="width: 766"]
<colgroup><col><col><col><col><col><col><col><col span="3"></colgroup><tbody>[TR]
[TD]Version[/TD]
[TD]Tipo Metrica[/TD]
[TD]Dimension GR[/TD]
[TD]Metrica[/TD]
[TD]Ejercicio[/TD]
[TD]Periodo[/TD]
[TD]Jerarquia[/TD]
[TD]AP[/TD]
[TD]AA[/TD]
[TD]Plan[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]as[/TD]
[TD]gr[/TD]
[TD]ventas[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]1[/TD]
[TD]gr[/TD]
[TD="align: right"]1600[/TD]
[TD="align: right"]1800[/TD]
[TD="align: right"]2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]as[/TD]
[TD]gr[/TD]
[TD]ventas[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]1[/TD]
[TD]gr[/TD]
[TD="align: right"]1600[/TD]
[TD="align: right"]1800[/TD]
[TD="align: right"]2000[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]ds[/TD]
[TD]gr[/TD]
[TD]ventas[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]1[/TD]
[TD]sdo[/TD]
[TD="align: right"]650[/TD]
[TD="align: right"]700[/TD]
[TD="align: right"]650[/TD]
[/TR]
[TR]
[TD="align: right"]1[/TD]
[TD]sa[/TD]
[TD]gr[/TD]
[TD]compras[/TD]
[TD="align: right"]2014[/TD]
[TD="align: right"]1[/TD]
[TD]sdo[/TD]
[TD="align: right"]750[/TD]
[TD="align: right"]800[/TD]
[TD="align: right"]800[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]re[/TD]
[TD]gr[/TD]
[TD]compras[/TD]
[TD="align: right"]2015[/TD]
[TD="align: right"]2[/TD]
[TD]sde[/TD]
[TD="align: right"]550[/TD]
[TD="align: right"]600[/TD]
[TD="align: right"]600[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]re[/TD]
[TD]gr[/TD]
[TD]compras[/TD]
[TD="align: right"]2015[/TD]
[TD="align: right"]2[/TD]
[TD]gr[/TD]
[TD="align: right"]2000[/TD]
[TD="align: right"]2500[/TD]
[TD="align: right"]2300[/TD]
[/TR]
[TR]
[TD="align: right"]2[/TD]
[TD]as[/TD]
[TD]gr[/TD]
[TD]ventas[/TD]
[TD="align: right"]2015[/TD]
[TD="align: right"]3[/TD]
[TD]LS[/TD]
[TD="align: right"]450[/TD]
[TD="align: right"]600[/TD]
[TD="align: right"]550[/TD]
[/TR]
</tbody>[/TABLE]


Code:
Public Function RecordsetFromSheet()
Dim cn As Object
Dim rs As Object




Set cn = CreateObject("ADODB.Connection")
cn.ConnectionString = OleDbConnectionString("xxxxx", "xxxx", "xx", "xxxxxxxxxx")
cn.Open


If CBool(cn.State And adStateOpen) = True Then 
    cn.Close
    Set cn = Nothing
End If


rs.Close
cn.Close
Set cn = Nothing


End Function








Function OleDbConnectionString(ByVal Server As String, ByVal Database As String, _
    ByVal UserName As String, ByVal Password As String) As String


    If UserName = "" Then
        OleDbConnectionString = "Provider=SQLOLEDB;Data Source=" & Server _
            & ";Initial Catalog=" & Database _
            & ";Integrated Security=SSPI;Persist Security Info=False;"
    Else
        OleDbConnectionString = "Provider=SQLOLEDB;Data Source=" & Server _
            & ";Initial Catalog=" & Database _
            & ";User ID=" & UserName & ";Password=" & Password & ";"
    End If


End Function
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,222,313
Messages
6,165,291
Members
451,950
Latest member
WH2000

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top