select * into ... using ODBC - syntax error
Can anybody help, please...
I'm trying to import table [tbl1] from Access into MSSQL Database using SQL statement below (in double quote) out of VB.NET application. When executed I'm receiving error for SQL statment: 'Incorrect syntax near the keyword IN.'
Dim SqlCommand As New System.Data.SqlClient.SqlCommand("SELECT * INTO [tbl1] FROM [tbl1] IN '' [ODBC;Driver={Microsoft Access Driver (*.mdb)};Dbq=\\Server1\C\db1.mdb;Uid=Admin;Pwd=;]", SqlConnection)
I'm using simmilar statement to transfer data from SQL to Access using ODBC Driver for SQL Server and that is working fine.
I'm realy confused?
[671 byte] By [
mikus] at [2007-11-11 8:17:56]

# 1 Re: select * into ... using ODBC - syntax error
You have a quotation mark between the word IN and the opening square bracket of your ODCB connection string. I'm surprised the above line compiles at all, since you have three quotation marks. What would the SQL statement look like if it weren't in a string literal?
# 2 Re: select * into ... using ODBC - syntax error
The second quotetion is not a double quote but two single quotes so I believe that is why string is readable. I also have another procedure that transferes data from SQL Server to Access and that is workinkg fine using basically the same syntax with just different ODBC driver (this time Sql Server Driver)
mikus at 2007-11-11 23:48:09 >

# 3 Re: select * into ... using ODBC - syntax error
I think the problem is that SQL Server does not support the "IN [connection string]" syntax. The simplest solution is probably to attach the destination table to your Access database and run the query from there.
# 4 Re: select * into ... using ODBC - syntax error
Thank you
Yes, that was the problem.
mikus at 2007-11-11 23:50:07 >
