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
Microsoft SQL Server 2005ASP.NETMicrosoft SQL Server 2008