1

I am fetching all the records from the Excel sheet and adding columns into the database according to the Excel header row. After fetching I alter the table and adding columns into the newly created table and it works perfectly fine. but when I add one more column into the excel file and running the query again it supposed to add the column which I have created in the excel file but instead, it gives me an error of Column already exists The query which I m running is

"ALTER TABLE " + name + " ADD " + cellValue + " varchar(5000)"

Thanks in advance..

1 Answer 1

2

If you want to create only columns that don't exist write your query like this

"ALTER TABLE " + name + " ADD if not exists " + cellValue + " varchar(5000)"
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.