I have a table that I insert data into using the following stored procedure:
My question is: Is it possible to make an updatequery that executes a stored procedure (usp_displayThe mAll) and then update my table (Totaler) with these data? And if it is - then how?
Code:
CREATE PROCEDURE [dbo].[usp_insertTotaler]
AS
BEGIN
SET NOCOUNT ON;
DECLARE @Periode DateTime, @NyPeriode DateTime
SET @NyPeriode = (SELECT Max(Periode) FROM InstPeriode)
IF EXISTS
(SELECT DISTINCT ip.Periode FROM InstPeriode ip LEFT OUTER JOIN Totaler t ON ip.Periode = t.Periode
WHERE t.Periode Is Null)
BEGIN
INSERT INTO Totaler(iNavn, Periode, SubBrutSum, BrutTotal)
EXEC dbo.usp_displayThemAll
@Periode = @NyPeriode
SELECT iNavn, Periode, SubBrutSum, BrutTotal
FROM Totaler
END
Comment