How to create column and copy another column into the newly created one
I'm trying to achieve a simple task, I create a new column in a table and immediately afterwards try to copy a value of some other column in the same table into the new created column but I got a
Invalid column name 'COMMENT_TMP'. error
The SQL is
Invalid column name 'COMMENT_TMP'.
ALTER TABLE TASK_COMMENT ADD COMMENT_TMP text;
开发者_运维问答UPDATE TASK_COMMENT SET TASK_COMMENT.COMMENT_TMP = COMMENT;
Add the batch delimiter and the table name in your update statement.
ALTER TABLE TASK_COMMENT ADD COMMENT_TMP text;
GO
UPDATE TASK_COMMENT SET COMMENT_TMP = COMMENT;
You first need to send theALTER
batch to the server before executing the UPDATE
. Add GO
after the ALTER
statement
精彩评论