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.

VersionTipo MetricaDimension GRMetricaEjercicioPeriodoJerarquiaAPAAPlan
1asgrventas20141gr160018002000
1asgrventas20141gr160018002000
1dsgrventas20141sdo650700650
1sagrcompras20141sdo750800800
2regrcompras20152sde550600600
2regrcompras20152gr200025002300
2asgrventas20153LS450600550

<colgroup><col><col><col><col><col><col><col><col span="3"></colgroup><tbody>
</tbody>


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
 

Some videos you may like

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.

Watch MrExcel Video

Forum statistics

Threads
1,127,931
Messages
5,627,690
Members
416,266
Latest member
stevenvanroeden

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
Top