Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Row to set IF

Author  Topic 

Ex
Posting Yak Master

166 Posts

Posted - 2005-02-24 : 17:38:55
hey all

trying to work out how to do this i have a stored procedure that was originally called from a cursor YUK! :)

cursors gone and now a temp table is being passed in (not much better but only good way to do it at the moment)

but i have a problem i am sure this will be easy but just cant get it

the input table has a column with PartentID
//@inputTable (ParentID,ChangeInSize,...)

this is my old code
SELECT @CurrSpares = SparesInBytes FROM ENTITY
WHERE EntityID = @ParentID AND MajorBuildNo = 0 AND
MinorBuildNo = 0 AND AutoSize <> 1

IF ((@CurrSpares - @ChangeInSize) < 0)
BEGIN
RETURN -1
END

just wondering how to do this condition in a set version? the only way i can think of is to put a identity column on the input table variable and do a while loop is there a better way?






nr
SQLTeam MVY

12543 Posts

Posted - 2005-02-24 : 19:35:21
if exists (select * from ENTITY e join #inputtable t on e.EntityID = t.ParentID and e.MajorBuildNo = 0 and e.MinorBuildNo = 0 and e.AutoSize <> 1 where e.SparesInBytes - t.ChangeInSize) < 0
begin
return -1
end


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -