abenitez77
Registered User.
- Local time
- Today, 09:51
- Joined
- Apr 29, 2010
- Messages
- 141
is there a way to export from ms access to SQL Server using vba code?
What are you trying to do? Is this a one time conversion or do you need to transfer data on a regular basis? Are the tables already built in SQL Server or do you need to also create them?
SSMA is the SQL Server Migration Assistant. The newest versions are problematic because for some reason MS has decided to no longer support 32-bit databases and that is the vast majority of all Access apps.
I would suggest using a third party app such as SQL Server Examiner Suite so you can avoid the "free" SSMA tool that will wreck you PC if you follow the MS directions for installing it. I still cannot open .mde or .accde or .accdr databases AT ALL since I followed the MS directions.
If you are moving big data from Access up to existing tables on SQL Server, note that it is incredibly slow through linked tables. I don't know if this applies to the upsizer in Access.
SQL Server has a very powerful Import Wizard that is much faster but it does take some time to get one's head around it.
Not any more you can't. MS deprecated it either in A2016 or A2013. The only thing left is the splitter that creates a separate Jet or ACE BE.You can use the upsizing wizard that is built into Access ...
- Database Tools ... Move Data .. SQL Server
AmzConn = "ODBC;Description=SQL PassThru;DRIVER={" & GBL_strDriverVersion & "};SERVER=" & AmzSrv & ";DATABASE=" & AmzDb & ";TRUSTED_CONNECTION=Yes;"
' Tried it this way..
DoCmd.TransferDatabase acExport, AmzConn, acTable, "ToolSettings", "ToolSettings"
'Then this way.
DoCmd.TransferDatabase acExport, "ODBC Database,ODBC;DSN=AmzExportToSQL;UID=;PWD=;LANGUAGE=us_english; DATABASE=Amazon_Global_Tool", acTable, "ToolSettings", "ToolSettings"
' I get the same Run-time error '13': type mismatch
First thing is to check the datatypes in the table to see if any are not supported in SQL Server
'##########################################
' GetConnectionString 04/08/2010
' Used to create a connection string
'############################################
Function GetConnectionString(strLinkType, _
strLinkServer, _
strLinkDatabase, _
strAppName, _
strLinkUsername, _
strLinkPassword) As String
Select Case strLinkType 'Get the link type to determine the connection string
#If SQL_DRIVER = "Native" Then
Case "SQL"
GetConnectionString = "ODBC;DRIVER={SQL Native Client};" & _
"SERVER=" & Nz(strLinkServer, "") & ";" & _
"DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
"APP=strAppName;" & _
"UID=" & Nz(strLinkUsername, "") & ";" & _
"PWD=" & Nz(strLinkPassword, "")
Case "SQL-Trusted"
GetConnectionString = "ODBC;DRIVER={SQL Native Client};" & _
"SERVER=" & Nz(strLinkServer, "") & ";" & _
"DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
"APP=strAppName;" & _
"Trusted_Connection=yes;"
#ElseIf SQL_DRIVER = "MDAC" Then
Case "SQL"
GetConnectionString = "ODBC;DRIVER={SQL Server};" & _
"SERVER=" & Nz(strLinkServer, "") & ";" & _
"DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
"APP=strAppName;" & _
"UID=" & Nz(strLinkUsername, "") & ";" & _
"PWD=" & Nz(strLinkPassword, "")
Case "SQL-Trusted"
GetConnectionString = "ODBC;DRIVER={SQL Server};" & _
"SERVER=" & Nz(strLinkServer, "") & ";" & _
"DATABASE=" & Nz(strLinkDatabase, "") & ";" & _
"APP=strAppName;" & _
"Trusted_Connection=yes;" & _
""
#End If
Case "Access"
If Nz(strLinkPassword, "") <> "" Then
GetConnectionString = "MS Access;" & _
"PWD=" & Nz(strLinkPassword, "") & ";" & _
"DATABASE=" & Nz(strLinkServer, "") & Nz(strLinkDatabase, "")
Else
GetConnectionString = "MS Access;" & _
"DATABASE=" & Nz(strLinkServer, "") & Nz(strLinkDatabase, "")
End If
Case Else
GetConnectionString = ""
End Select
End Function