If I have two tables A and B:
A(AId, a1, a2)
B(BId, AId, b1, b2, b3)
On first thought , I wanted to write a sp (stored procedure) incorporates the two insert statements.
But, on a second I thought I felt it would be nicer if I had a separated sp to do an insert for the table B and another to do an insert for table A while calling the insert sp for B from within A.
Please which is the best approach?
That depends: If you assume that you will be able to reuse the SP for B in another context (i.e. outside the SP for A), make a separate SP. Otherwise, having just one SP (in particular, if it’s only a simple SP with two INSERT statements) might reduce the complexity of your DB layer.