Having an issue then trying to bulkload to a temporary table:
Temp Table Creation Script:
CREATE TABLE ##DummyTable_Site ( [DimId] int NOT NULL, [Type] nvarchar(200), [Status] nvarchar(200), [Grp] nvarchar(200), [Cat] nvarchar(200), [Desc] nvarchar(500), [Name] nvarchar(200), [Cd] nvarchar(200) NOT NULL,[CRD] datetime2, [CUId] int, [DSId] int)
connection.newBulkLoad('##DummyTable_Site', { keepNulls: true }, ... );
... Columns and Rows added here
connection.execBulkLoad(bulkLoad);
After executing execBulkLoad getting the below error
Error:
message:"An unknown error has occurred. This is likely because the schema of the BulkLoad does not match the schema of the table you are attempting to insert into."
+1, when I try to update an existing table with an additional column, I get the same error. Any ideas how to fix it? Didn't find anything in the documentation 馃様
@codethyme Can you show your column and row addition code? The error might indicate that the columns and rows being added don't match the order of the temp table columns
@mikalai-sokarau Are the rows and columns being added match the table columns? Perhaps a code example could be helpful to look at
Hi @mikalai-sokarau, I just went over the doc briefly and found that it actually mentioned that the schema for add columns should match the original table's schema. That may actually be the cause of your error? http://tediousjs.github.io/tedious/bulk-load.html#function_addColumn
Hi, guys, thank you for your answers and link to the doc!
Indeed, I found out that schemas are different 馃槼
Is it possible to dynamically change the table schema (add one more column) with tedious API?
Or maybe someone can suggest a standard approach to do this manipulation?
You can try just using a regular SQL command such as
let sqlCommand = 'ALTER TABLE table_name ADD column_name datatype;'
Then using the regular tedious API connection.execSql(sqlCommand);
. See if that works?
Hi @IanChokS, thank you very much, it helped!
@codethyme Does the above solution work for you also? Closing this for now.