Handling Quotation when Inserting Table to SQL Database
1 回表示 (過去 30 日間)
古いコメントを表示
I have a table that looks like this:
id = [1 2]';
name = {'abc', 'a''bc'}';
data = table(id,name);
disp(data)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191231/image.png)
Now when I tried to insert this table to a MS SQL database, I got this error:
hdr = {'id','name'};
insert(conn, 'userName.dbName.tableName', hdr, data)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/191232/image.png)
Apparently it's because of the single quotation mark in the second row of the table, as I can see the first row got inserted successfully.
Thoughts?
2 件のコメント
Kojiro Saito
2018 年 6 月 13 日
I cannot reproduce this issue in MATLAB R2018a with SQL Server 2016. Which MATLAB and SQL Server versions are you using?
採用された回答
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Database Toolbox についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!