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]
[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