Run-time error '-2147221348(8004009c)':
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'Database'.
[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near the keyword 'Database'.
Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.
View products that this article applies to.
sp_renamedb 'My Database', 'MyDatabase'
'create the object
Dim mySQLserver As SQLDMO.SQLServer
Dim myDatabase As SQLDMO.Database
Set mySQLserver = New SQLDMO.SQLServer
Set BulkCopy = New SQLDMO.BulkCopy
mySQLserver.EnableBcp = True
'connect to the SQL Server
mySQLserver.Connect "yourSQLServer", "YourLogin", "YourPassword"
With BulkCopy
.DataFileType = SQLDMODataFile_NativeFormat
.MaximumErrorsBeforeAbort = 1
.UseBulkCopyOption = True
.UseExistingConnection = True
'specify the path where the table is to be copied
.DataFilePath = "C:\mytable.bcp"
'export the data from the table in My Database
mySQLserver.Databases("My Database").Tables("MyTable").ExportData BulkCopy
End With
Keywords: KB817848, kbbug, kbdatabase, kbexport, kbsqlclient, kberrmsg