running32
asked on
Update Query
Can anyone tell me why my update query does not work. I get the error.
Server: Msg 116, Level 16, State 1, Line 17
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
UPDATE up
SET up.ref = up.ref,
up.pdate = up.pdate,
up.problem = up.Problem,
up.Branch = up.Branch ,
up.Val = v.val,
up.moddate = v.modified ,
up.type = t.name
from docsdb.dbo.vtab0010 v, docsdb.dbo.temp te, docsdb.dbo.updated up, docsdb.dbo.types t
where v.val in
(select distinct te.ref,
te.pdate,
v.val,
te.problem,
te.branch,
v.modified,
t.name
from docsdb.dbo.vtab0010 v
join docsdb.dbo.docs d on v.docid = d.docid
join docsdb.dbo.types t on d.typid = t.typid
join docsdb.dbo.temp te on v.val = te.val
inner join (select v.val, max(v.modified) as modified from docsdb.dbo.vtab0010 v group by v.val)
x on v.val = x.val and v.modified = x.modified
where (v.val = te.val and te.problem = 'No Card'))
Server: Msg 116, Level 16, State 1, Line 17
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
UPDATE up
SET up.ref = up.ref,
up.pdate = up.pdate,
up.problem = up.Problem,
up.Branch = up.Branch ,
up.Val = v.val,
up.moddate = v.modified ,
up.type = t.name
from docsdb.dbo.vtab0010 v, docsdb.dbo.temp te, docsdb.dbo.updated up, docsdb.dbo.types t
where v.val in
(select distinct te.ref,
te.pdate,
v.val,
te.problem,
te.branch,
v.modified,
t.name
from docsdb.dbo.vtab0010 v
join docsdb.dbo.docs d on v.docid = d.docid
join docsdb.dbo.types t on d.typid = t.typid
join docsdb.dbo.temp te on v.val = te.val
inner join (select v.val, max(v.modified) as modified from docsdb.dbo.vtab0010 v group by v.val)
x on v.val = x.val and v.modified = x.modified
where (v.val = te.val and te.problem = 'No Card'))
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.