Created
August 31, 2021 09:11
-
-
Save yahyaahrika/e2990b257ffa5f8a4e41890b9bd0774b to your computer and use it in GitHub Desktop.
sql server ProcedureStock loop to other Procedure by date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE "SP_Loop_Monteur_Gewinn"( | |
@StartDate Date, | |
@FinDate Date | |
) | |
AS BEGIN | |
DECLARE @Counter INT | |
DECLARE @Lenght INT | |
DECLARE @CalculDateStart DATE | |
--SET @StartDate = '08/01/2021' | |
--SET @FinDate = '08/13/2021' | |
SET @Lenght = 0 | |
SET @CalculDateStart = CAST(@StartDate As date) | |
SET @Counter= DATEDIFF(DAY , @StartDate , @FinDate ); | |
WHILE @Lenght <= @Counter | |
BEGIN TRY | |
PRINT @CalculDateStart | |
EXEC SP_Statistique_CostAds | |
@dateStart = @CalculDateStart, | |
@dateFin = @CalculDateStart; | |
SET @CalculDateStart = DATEADD(DAY , 1 , @CalculDateStart ) | |
SET @Lenght = @Lenght + 1 | |
END TRY | |
BEGIN CATCH | |
SELECT | |
ERROR_NUMBER() AS ErrorNumber, | |
ERROR_STATE() AS ErrorState, | |
ERROR_SEVERITY() AS ErrorSeverity, | |
ERROR_PROCEDURE() AS ErrorProcedure, | |
ERROR_LINE() AS ErrorLine, | |
ERROR_MESSAGE() AS ErrorMessage; | |
END CATCH | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment