I am trying to update a number of rows in a table. I am retrieving the number of rows with a query and assigning a local variable. Here is the code segment.
select top 1 @MS= UPSMaxSize from SorterChuteTemp where chutestatus = 'SUS' order by chuteID
if(@MS > @Size) -- will fit
begin
-- assign the chutes
UPDATE sorterchutetemp
SET chutestatus = 'ACT'
FROM (SELECT TOP @ms * FROM sorterchutetemp ORDER BY chuteid
WHERE chutestatus = 'SUS'
end
else -- won't fit
begin
-- generate message
end
I'm getting an error message on the FROM (SELECT line.
Can anyone help?
Thanks in advance!
Dave
select top 1 @MS= UPSMaxSize from SorterChuteTemp where chutestatus = 'SUS' order by chuteID
if(@MS > @Size) -- will fit
begin
-- assign the chutes
UPDATE sorterchutetemp
SET chutestatus = 'ACT'
FROM (SELECT TOP @ms * FROM sorterchutetemp ORDER BY chuteid
WHERE chutestatus = 'SUS'
end
else -- won't fit
begin
-- generate message
end
I'm getting an error message on the FROM (SELECT line.
Can anyone help?
Thanks in advance!
Dave