简体   繁体   中英

Update a column using subquery or join

I need to update the 'DA_ArticleDetails' column of table1 using the resul from the select query. I tried something like this:

UPDATE table1 
SET [DA_ArticleDetails] =
(
select RIGHT([DA_ArticleDetails], 8000)
from table1
)

but its giving error:

Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.

Could anyone help me how to update the column?

UPDATE table1 
SET [DA_ArticleDetails] = RIGHT([DA_ArticleDetails], 8000)
from table1

You can simply call the following query

UPDATE table1 
SET [DA_ArticleDetails] =RIGHT([DA_ArticleDetails], 8000)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM