用于自动执行SSIS包和存储过程的脚本

时间:2015-07-29 14:56:41

标签: sql-server tsql stored-procedures ssis sql-server-2012

我试图获取一个脚本来自动化多个变量的SSIS包和存储过程执行在前一个变量上成功,变量是日期{201412,201501,201502等等...} 程序执行的脚本是

`exec [dbo].[ALIM_AGE_RANGE]
 exec [dbo].[ALIM_CATEGORY_EMPLOYEE]
 exec [dbo].[ALIM_CURRENCY]  201503
 exec [dbo].[ALIM_EMPLOYEE]
 exec [dbo].[ALIM_HR_DISCIPLINE]
 exec [dbo].[ALIM_ORGANIZATION]
 exec [dbo].[ALIM_RECRUITMENT_REASON]
 exec [dbo].[ALIM_ROLE]
 exec [dbo].[ALIM_STATUS_EMPLOYEE]
 exec [dbo].[P_ALIM_HR_FACT] 201503`

谢谢

回答如何自动化存储过程以一个接一个地运行一个变量的多个值:(仍然看看如何为ssis包执行此操作)

USE [HR_DTM]
GO

IF (OBJECT_ID('tempdb..#tab') IS NOT NULL)
BEGIN
truncate table #tab
end

go
        exec [dbo].[P_ALIM_AGE_RANGE]
        exec [dbo].[P_ALIM_CALENDAR]
        exec [dbo].[P_ALIM_CATEGORY_EMPLOYEE]
        exec [dbo].[P_ALIM_COUNTRY]

        EXEC [dbo].[P_ALIM_EMPLOYEE]
        exec [dbo].[P_ALIM_GLOBAL_GRADE]
        exec [dbo].[P_ALIM_HR_DISCIPLINE]
        exec [dbo].[P_ALIM_ORGANIZATION]
        exec [dbo].[P_ALIM_RECRUITMENT_REASON]
        exec [dbo].[P_ALIM_ROLE]
        exec [dbo].[P_ALIM_STATUS_EMPLOYEE]



IF (OBJECT_ID('tempdb..#tab') IS NULL)
BEGIN
CREATE TABLE #tab(id INT IDENTITY(1,1), param_value int);
END


INSERT INTO #tab(param_value)
VALUES (201412), (201501),  (201502), (201503), (201504),(201505), (201506),(201507), (201508), (201509); -- ...

DECLARE @counter INT = 1,
    @param bigint;
    --@param2 datetime = convert (datetime, @param) @param;

WHILE @counter <= (SELECT MAX(id) FROM #tab)
BEGIN
 SELECT @param = param_value
FROM #tab
WHERE id = @counter;


        exec [dbo].[P_ALIM_CURRENCY] @param


        exec [dbo].[P_ALIM_HR_FACT] @param

SET @counter += 1;
END

0 个答案:

没有答案