开发者

How to create column and copy another column into the newly created one

开发者 https://www.devze.com 2023-02-11 08:34 出处:网络
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

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

0

精彩评论

暂无评论...
验证码 换一张
取 消