Incomplete table using SQLread

2 次查看(过去 30 天)
Hi everyone,
I have an issue with sqlread (or sqlread has an issue with me, I don't know!). I make the connection just fine, read a table from the right database and all that, and I get no error messages. The table contains 600+ rows and 12 columns, and the script is of course just using matlabs built-in functions:
conn = database('MyDatabaseName','','');
tablename='Exampletable';
rows = sqlread(conn,tablename);
Column 12, which is a free text column for comments, contains the "No comments" string in all rows on the server (I know this, because in Microsoft SQL Server Management Studio, it shows up as "No comments"). But! In my script, the "rows" table column 12 just says "N", in all cases.
And furthermore, when I then make a table that is identical in syntax to "Exampletable", and use the sqlwrite function, and then look at the data again via Microsoft SQL Server Management Studio, the first row I added has "N", the next now "NN", and the third "NNN" and so on.
sqlwrite(conn,tablename,IdenticalTable);
Has anyone encountered something like this before, and who can explain why this happens? The database is one which I "inherited" from a colleague who used a different program to create the original table and store the first ~600 entries. It is worth pointing out that the first 11 columns (which are a mix of numbers and text strings) go into the server just fine, and I also read them just fine.
(Edit: by the way, if I use the sqlwrite function in this manner, the "NNNNNNNN" issue does not happen... so that part is "fixed" but I would still like to know why it happens, and also why I can't read the table properly):
for i=1:size(IdenticalTable,1)
sqlwrite(conn,tablename,IdenticalTable(i,:));
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

产品


版本

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by