Hi,This is my first post so please bare with me if I'm in the wrong forum.I'm quite new to SQL Server and am trying to do the following:I have three tables - Products, Transactions and Deliveries. I want to return all products regardless of whether thay have a transaction or not for a particular delivery. So the DeliveryID has to be the parameter. I have tested the query side of things by using two views as below (View 1 calling View 2 to get a result)View1SELECT p.ProductRef, ISNULL(t.QtyDelivered, 0) AS Delivered, ISNULL(t.QtyReturned, 0) AS Returned, ISNULL(t.QtySampled, 0) AS SampledFROM dbo.Products AS p LEFT OUTER JOIN dbo.View2 AS t ON p.ProductID = t.ProductID
View2SELECT TransactionID, ProductID, QtyDelivered, QtyReturned, QtySampled, Amount, Date, DeliveryID, TransactionGroupIDFROM dbo.TransactionsWHERE (DeliveryID = 2)
The data returned is exactly what I want. However, I need to set DeliveryID as a paramater so I think I need to use two stored procedures. One calling the other. I'm not sure if this is even possible? I've created the two SP's and tried running them in some VB code but I get an error when the first SP calls the second SP.I originally tried to get the data with two Outer joins so I could use a single SP but this got too complicated for me!
I guess my first question to get me to the next stage is to clarify whether it is possible to call an SP from within another SP?Many thanks in advance.