Tag Info

New answers tagged

5

You have to break it up into batches because the [Column] does not exist since the statements are being parsed as one batch so it cannot see the new column, hence you receive the error. Once you break it up into batches with GO statement the column will be added to the table and then your next batch updating the new column will be successful. Full example: ...


1

You might need INFORMATION_SCHEMA.KEY_COLUMN_USAGE You would have to issue this query SELECT column_name FROM information_schema.key_column_usage WHERE table_schema='$db' AND table_name='$table' AND constraint_name='PRIMARY'; This will retrieve every column in the PRIMARY KEY. You could then make this query generate the ALTER TABLE clauses for you as ...


1

I am not able to reproduce the issue with the code you have given. Am getting only one warning message in the line UPDATE #tmpImportData SET group_id = CAST(group_id_text AS INT) like invalid column name group_id(its because the column is added to the temp table dynamically) Can you recheck whether you are getting the issue with code you have given in ...


3

You need to perform the update in dynamic SQL too (or just create the table with all columns in the first place). The error is happening because the update with the new column is being parsed before the dynamic SQL has run. As an aside, you are probably only getting this error if you try to execute the stored procedure and choose 'Display estimated ...


2

Try to repair the table: mysql> LOCK TABLES `fruitful_user_count` WRITE; mysql> CREATE TABLE `fruitful_user_count_new` LIKE `fruitful_user_count`; mysql> INSERT INTO `fruitful_user_count_new` SELECT * FROM `fruitful_user_count`; mysql> RENAME TABBLE `fruitful_user_count` TO `fruitful_user_count_old`; mysql> RENAME TABLE ...


2

Suggested solutions: Execute the following command REPAIR TABLE table_name; If that (step one) doesn't help try to change the temp directory in the cnf file to new location with bigger space; If step one and two did not help you need to restore the database to previous stage.



Top 50 recent answers are included