Operating system: 64-bit win8.1
Software version: matlab2013a SQL Sever R2
Create a database and a corresponding table
Create a database and a table in it, steps are not described in detail
Configure ODBC
The ODBC (Open database Connectivity), open databases interconnect, is an integral part of the database in the Microsoft Open Services architecture, which establishes a set of specifications and provides a set of standard APIs (application programming interfaces) for database access.
Open Control Panel , System and security management tools, Locate the ODBC data source (64-bit) double-click to open it because my operating system is 64-bit
Add a button when you come in
Select SQL Server in a new window and complete the machine
The new Data Source window pops up, the first row name is entered to connect to the database name (here is my first step to create a good database neu), the second line description can be arbitrarily described in the data source (Neusource), the third row of the Server drop-down box select your SQL Server server name, If the drop-down box is empty, enter the database server name manually and log in to the database as visible my database server is named DELL-PC
Complete the information as completed
Stand-alone test data source in the dialog box that pops up
To see if the test was successful
Click OK to finish creating the data source Neu
MATLAB for database operations
The first thing to do is connect to the database and enter the commands. Conn is a variable that holds the database connection string, Neu is the data source (that is, the name of the database to connect to), and the other two fields are the SQL Server login and the login password
Then verify the database connection status
Next, you can work with the database in MATLAB
For example, insert the MATLAB matrix variable matvar into the table dbo.table of the database neu. Using the Fastinsert statement, Conn We have already defined, NEU.dbo.Table means that the database name is NEU, the inserted table is dbo.table, and the col1,col2,col3 in curly braces is the column name in the table. Matrix variable The number of columns in MATLAB must be the same as the number of columns in braces to insert success
The command implementation inserts three columns of MATLAB matrix variable Matvar into the three columns of col1, col2, col3 of the dbo.table table in the SQL Server database neu
Reference: http://wenku.baidu.com/view/ebdef627af45b307e87197b8.html
Http://wenku.baidu.com/link?url=IFDpmvzW5K8E6_zivowAnWulJzduJ4xfvQR9HrjjeCemx5NKNnHKyh7I7X_h_ Qyc7irqhjmijhkk2arxebplh65m71lebhnskqlvnharujk
MATLAB Connect to SQL database