Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bulkload to Temporary Table Error #1005

Closed
codethyme opened this issue Nov 16, 2019 · 7 comments
Closed

Bulkload to Temporary Table Error #1005

codethyme opened this issue Nov 16, 2019 · 7 comments
Labels
Idle Waiting for more information for a while...

Comments

@codethyme
Copy link

codethyme commented Nov 16, 2019

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."

@mikalai-sokarau
Copy link

+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 😔

@IanChokS
Copy link
Member

IanChokS commented Nov 18, 2019

@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

@MichaelSun90
Copy link
Contributor

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

@mikalai-sokarau
Copy link

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?

@IanChokS
Copy link
Member

IanChokS commented Nov 19, 2019

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?

@mikalai-sokarau
Copy link

Hi @IanChokS, thank you very much, it helped!

@IanChokS IanChokS added the Idle Waiting for more information for a while... label Dec 13, 2019
@IanChokS
Copy link
Member

@codethyme Does the above solution work for you also? Closing this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Idle Waiting for more information for a while...
Projects
None yet
Development

No branches or pull requests

4 participants