I am importing some data from a database using the following code:
SRVname='theserver';
conn=database(SRVname,'','');
tablename='tablename\moretablename';
data = sqlread(conn,tablename);
However Matlab returns the following error:
Error using database.odbc.connection/sqlread (line 310)
ODBC Driver Error: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Incorrect syntax near '\'.
I tried to add a "\" or a "/" but neither worked. The connection and data loading works perfectly with other tables in the same server and database but without the "\" in the name.
I believe that you need to quote the table name using the SQL identifier quoting operator, [...]
.
tablename='[tablename\moretablename]';
data = sqlread(conn,tablename);