MATLAB Answers

0

Query specific catalog in MS SQL DB

Asked by Anthony Crockford on 18 Jan 2019
Latest activity Answered by Arpan Badeka on 4 Apr 2019
Hi,
I need to query an MS SQL data base but I do not know how to select the specific catalog of interest.
Here is my SQL DB architechture:
xxxx.windows.net
- Databases
+ System Databases
+ Database1
+ Database2
...
The connection is defaulted to master catalog but I need tables in Database1, Database2 ...
I have the database toolbox installed and am running R2018a using ODBC Driver 17 for SQL Server.
Can anyone send a few lines of code to help?
Many thx indeed.

  0 Comments

Sign in to comment.

1 Answer

Answer by Arpan Badeka on 4 Apr 2019

Hi Anthony
Use the following query after connecting to the database to get the list of all the tables:
tableList = sqlread(conn, "tables", 'Catalog', Database1, 'Schema', 'information_schema');

  0 Comments

Sign in to comment.