samedi 14 mars 2015

where is the error? if exists

what a hell am i doing wrong? why i'm gettin this error?


let me try to explain:


the table [_AUX] receive a value from a asp page (word 'TOJ' was subimited by a form).


based on this information, i'm trying to create a trigger to update another table called [dbo].[TODOS]. but i have to select only one row randomly that has the 'false' value and then change it to 'true'.


check my code:



IF EXISTS (
select top 1 A.flag
from [DBO].[_AUX] AS A
WHERE a.flag = 'TOJ' order by a.ID_AUX desc
)

update DBO.TODOS set DBO.TODOS.[TOJ_FLAG]='true'
where DBO.TODOS.[TOJ_FLAG] =
(
select top 1 t.[toj_flag], t.TODOS
FROM dbo.todos as t
where t.toj_flag = 'false'
ORDER BY NEWID()
)


im receiving a error from sql management studio:



Msg 116, Level 16, State 1, Line 14


Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.



plz help!!!!





Aucun commentaire:

Enregistrer un commentaire