2016-09-22 6 views
-1
DECLARE @StartDate DateTime; 
DECLARE @EndDate DateTime; 
DECLARE @CurrentDate DateTime; 
DECLARE @Status INT; 

Set @StartDate = '2016-08-19 00:00:00.000'; 
Set @EndDate = '2016-08-20 00:00:00.000' 
Set @CurrentDate = @StartDate 

While (@CurrentDate <= @EndDate) 
BEGIN 
    UPDATE [dbo].[IntegrationLog] 
    SET [CUSTOMER] = @CurrentDate, [PRODUCT] = @CurrentDate, 
     [ORDER] = @CurrentDate, [ORDERLINE] = @CurrentDate, 
     [DELIVERYNOTE] = @CurrentDate, [DELIVERYNOTEITEM] = @CurrentDate, 
     [INVOICE] = @CurrentDate, [INVOICEITEM] = @CurrentDate, 
     [WAREHOUSE] = @CurrentDate, [DELIVERYRETURN] = @CurrentDate 

    declare @output_execution_id bigint 
    exec dbo.Execute_ssis_Package @output_execution_id output 

    Set @Status = (SELECT [STATUS] FROM [SSISDB].[internal].[operations] 
        WHERE operation_id = @output_execution_id) 

    While (@Status != 7) 
    Begin 

     WAITFOR DELAY '00:00:59'; 
     CONTINUE; 
     IF (@STATUS = 4) 
     Break; 
    END 
    SET @StartDate = DATEADD(DAY, 1, @StartDate); 
End  
+1

のためにループされていませんか? 'mysql'、' postgresql'、 'sql-server'、' oracle'、 'db2'のどれかを指定するタグを追加してください。 –

+0

SQL SERVER 2012 –

+0

このクエリは最初の開始日に実行されており、翌日には更新されません。 –

答えて

0
DECLARE @StartDate DateTime; 
DECLARE @EndDate DateTime; 
DECLARE @CurrentDate DateTime; 
DECLARE @Status INT; 

Set @StartDate = '2016-08-19 00:00:00.000'; 
Set @EndDate = '2016-08-20 00:00:00.000' 
Set @CurrentDate = @StartDate 

While (@CurrentDate <= @EndDate) 
BEGIN 
    UPDATE [dbo].[IntegrationLog] SET [CUSTOMER] = @CurrentDate,[PRODUCT] = @CurrentDate,[ORDER] = @CurrentDate,[ORDERLINE] = @CurrentDate, 
    [DELIVERYNOTE] = @CurrentDate,[DELIVERYNOTEITEM] = @CurrentDate,[INVOICE] = @CurrentDate,[INVOICEITEM] = @CurrentDate, 
    [WAREHOUSE] = @CurrentDate, [DELIVERYRETURN] = @CurrentDate 

    declare @output_execution_id bigint 
    exec dbo.Execute_ssis_Package @output_execution_id output 

    Set @Status = (SELECT [STATUS] FROM [SSISDB].[internal].[operations] WHERE operation_id = @output_execution_id) 

    While (@Status != 7) - 
    Begin 

    WAITFOR DELAY '00:00:59'; 
    CONTINUE; 
    IF (@STATUS = 4) 
    Break; 
    END 
SET @CurrentDate [email protected]+1; 
End  
+0

あなたが直面している問題はWhile While Status!= 7ここで何が起こるかは、ステータスが7になっていない場合です。最初の日は継続しています。ここであなたの不意打ちを変えよう(@Status!= 7) - Begin WAITFOR DELAY '00:00:59 '; 続きます。 –

+0

ありがとうAlfaiz Ahmed ... –

関連する問題