I've pasted some code that a friend gave me for copying a table from an SQL server to a database held on a local pc, my question is, is there a way of doing this in reverse, i.e from a locally held database to the sql server?
Function Copy_Table_From_Sql_Server(ByVal NewTable As String, ByVal ExistingTable As String, ByVal LocalDb As Database) As Boolean
On Error GoTo ErrHandler
CopyTable: 'try and copy before deleting the existing table
'just incase it doesn't exist in the external db
Sql = "SELECT * INTO [" & NewTable & "] FROM " & _
"[ODBC;Driver=SQL Server; SERVER=10.234.95.121;DATABASE=Titan;UID=UserName;PWD=Password;].[" & ExistingTable & "];"
Copy_Table_From_Sql_Server = True
LocalDb.Execute "drop table [" & NewTable & "] ;" ' drop the old table
Select Case Err
Resume Next ' table didn't exist to begin with
Resume DeleteTable ' table allready existed
Exit Function ' table doesn't exist in external db
' MsgBox Err.Number & " " & Err.Description