Control the import options by creating an SQLImportOptions
object. Then, retrieve the default import options for several columns from a database table. Specify the columns to retrieve by using the database column names.
This example uses the patients.xls
spreadsheet, which contains the columns LastName
, Age
, and Location
. Also, the example uses a Microsoft® SQL Server® Version 11.00.2100 database and the Microsoft SQL Server Driver 11.00.5058.
Create a database connection to a Microsoft SQL Server database with Windows® authentication. Specify a blank user name and password.
Load patient information into the MATLAB® workspace.
Create the patients
database table using the patient information.
Create an SQLImportOptions
object using the patients
database table and the databaseImportOptions
function.
Specify the names of the database columns in the patients
database table.
Retrieve and display the default import options for the specified database columns.
varOpts =
1x3 SQLVariableImportOptions array with properties:
Variable Options:
(1) | (2) | (3)
Name: 'LastName' | 'Age' | 'Location'
Type: 'char' | 'double' | 'char'
FillValue: '' | [NaN] | ''
To access sub-properties of each variable, use getoptions
To modify the variable import options, see the setoptions
function.
Delete the patients
database table using the execute
function.
Close the database connection.