我可以更新子查询返回超过1个值的列

时间:2015-08-08 19:07:51

标签: sql-server-2012

[![从具有不同DOCID的一张表中搜索结果] [1]] [1]

[1]:http://i.stack 强文 .imgur.com / vLPwr.jpg

我想在同一个表中更新我从另一个docid获取的记录

我试试

Declare
@DOCID nvarchar(100),
@SBJCODE NUMERIC(3,0),
@SUBJECT_ORDER NUMERIC(9,0),
@IS_ACTIVE NUMERIC(9,0)
select @SBJCODE = sbjcode from ASSIGNMENT_SUBJECTS where DOCID =    '274FC727-4C5A-467F-A2CC-14CC14275E0A'  
select @IS_ACTIVE = IS_ACTIVE from ASSIGNMENT_SUBJECTS where DOCID='274FC727-4C5A-467F-A2CC-14CC14275E0A'
select @SUBJECT_ORDER = SUBJECT_ORDER from ASSIGNMENT_SUBJECTS where DOCID = '274FC727-4C5A-467F-A2CC-14CC14275E0A'
UPDATE ASSIGNMENT_SUBJECTS SET SUBJECT_ORDER = @SUBJECT_ORDER, IS_ACTIVE = @IS_ACTIVE 
WHERE DOCID  = 'ACC4A511-4692-49DA-9FC9-F68090862EAC' AND SBJCODE = @SBJCODE

,结果是

(0行(s)受影响):/

任何人都可以帮助我

0 个答案:

没有答案