sqlwrite object already exists

조회 수: 3 (최근 30일)
Jakob B. Nielsen
Jakob B. Nielsen 2021년 5월 26일
댓글: Jakob B. Nielsen 2021년 5월 26일
Greetings excellent people!
(I am aware that a question already exists with roughly the same name, but it is several years old and does not seem to pertain to my problem).
I have run into the following error:
Error using database.odbc.connection/sqlwrite (line 144)
ODBC Error: ODBC Driver Error: ODBC Driver Error: [Microsoft][ODBC SQL Server Driver][SQL Server]There is already an object named 'Declared_values' in the
database..
Now, the sqlwrite function documentation says that if a table already exists in the sql database, the function appends the data in the MATLAB table as rows in the existing database table. I am at a loss here! I would welcome any suggestions. I have checked spelling, capital/noncapital letters, conn.message returns [], and I can both find and edit the database in Microsoft SQL Server Manager, which means I have edit rights. If I run
test = sqlread(conn,tablename);
It gives me the proper data from the table. But
sqlwrite(conn,tablename,data);
returns the error above.
I would very much appreciate any insight you can give me in this regard!
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2021년 5월 26일
Jakob - without knowing exactly what this error message means, are you inserting/writing new data into the table or trying to update existing data. The error message suggest (to me) that you are attempting to write data that already exists within the table.
Jakob B. Nielsen
Jakob B. Nielsen 2021년 5월 26일
Hi Geoff,
There is a table named 'Declared_values' in the database (it is the one referenced in the error message), into which I post monthly KPI figures. The data I want to put in should append to the existing table, and there is a date-time stamp included in the data so no two entries will ever be identical. So it should be an insert case, not a replace case.
It might be a helpful addition that the same identical code worked fine last a couple of months ago, but I recently got a new work PC. It is the same version of matlab, however, but in case this detail might help ring a bell for someone...

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by