行を返す必要があります:
.NET[tableReturn] = select top(1) * from [table] where x = 0 order by desc
しかし同時に、私はそれを更新する必要があります:
update [table] set x = 1 where [id] = .NET[tableReturn].[id]
この行のすべてのデータが必要です
同じクエリで可能ですか?
行を返す必要があります:
.NET[tableReturn] = select top(1) * from [table] where x = 0 order by desc
しかし同時に、私はそれを更新する必要があります:
update [table] set x = 1 where [id] = .NET[tableReturn].[id]
この行のすべてのデータが必要です
同じクエリで可能ですか?
これを試して
with cte as (select top(1) * from [table] where x=0 order by 1 desc)
update [table] set x=1 from cte join [table] c on c.id =cte.id;
ストアド プロシージャを使用します。ストアド プロシージャでは、必要な数のクエリを実行できます。
これがないと、複数のクエリを個別に呼び出す必要があります。
お役に立てれば。
単一のクエリで列を更新するには、以下のクエリを試してください。
update [table] set x = 1 where x = (select cte.x from (select top(1) * from [table] where x = 0 order by x desc) cte)
注:-しかし、更新された列はID列であってはなりません