ayha1999
asked on
Stored Pocedure
How can I execute all the three sql statments below in single stored procedure? if the first statement is returned no row, then only I want to execute the second and third statments.
SELECT a.* FROM Table1 a INNER JOIN Table2 b
ON a.PartNo = b.PartNo and a.StoreID = b.StoreID Where b.QtyIn >
a.Stock and b.Id=@Id
UPDATE Table1 SET Stock = P.Stock - PI.QtyIn from
Table1 as P Inner Join Table2 as PI on P.PartNo=PI.PartNo and
P.StoreID = PI.StoreID WHERE PI.Id=@Id
delete from Table2 where Id=@id
thanks
ayha
SELECT a.* FROM Table1 a INNER JOIN Table2 b
ON a.PartNo = b.PartNo and a.StoreID = b.StoreID Where b.QtyIn >
a.Stock and b.Id=@Id
UPDATE Table1 SET Stock = P.Stock - PI.QtyIn from
Table1 as P Inner Join Table2 as PI on P.PartNo=PI.PartNo and
P.StoreID = PI.StoreID WHERE PI.Id=@Id
delete from Table2 where Id=@id
thanks
ayha
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Good point. Wasn't paying attention :)
ASKER
I have already noticed the missing 'NOT'. Is it possible to return 0 if no update occured and 1 for the update?
thanks
thanks
ASKER
thanks for your help.
ayha
ayha