loading data on weekly basis
Hello friends, DECLARE @query varchar(50) DECLARE @query1 varchar(8) DECLARE @query2 varchar(30) SET @query = 'SELECT * FROM CCMS_STAT..dbo.eCallByCallStat' SET @query1 = cast(DATEPART(YYYY, GETDATE()) AS varchar(4)) + cast(DATEPART(M, GETDATE()) AS varchar(2)) + cast(DATEPART(D, GETDATE()) AS varchar(2)) SET @query2 = query + query1 EXEC sp_executeSQL @query2 Above query results 'SELECT * FROM CCMS_STAT..dbo.eCallByCallStat20110524' am using this cammands in my oledb source as my table name changes dynamically..................by using this ll get the current date data but i need last six days data to load hw to achive this can anyone help regarding this in ssis.....................
May 24th, 2011 6:14am

Why don't you use CDC in SQL 2008 please visit here http://www.mssqltips.com/tip.asp?tip=1755http://uk.linkedin.com/in/ramjaddu
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 6:31am

Hi Sandyzzz, 1) The best way is to frame the query in a script task and create a variable to store sql command. 2)Use the command varaible in OLEDB source. 3)USe a for loop to loop over for the last 6 days , from getdate() - 6 to getdate() and for each date frame the sql string varaible and execute the data flow task. Hope it is useful.Happy to help! Thanks. Regards and good Wishes, Deepak.
May 24th, 2011 6:59am

Use this code as data source DECLARE @query varchar(50) DECLARE @query1 varchar(8) DECLARE @query2 varchar(8000) SET @query = 'SELECT * FROM CCMS_STAT..dbo.eCallByCallStat' SELECT @query2 = '' Declare @CurrentDate Datetime Declare @RunningDate DateTime Declare @DateLoop int SELECT @CurrentDate = GETDATE() SELECT @DateLoop = 0 WHILE @DateLoop <= 6 BEGIN IF @DateLoop = 0 SELECT @RunningDate = @CurrentDate ELSE SELECT @RunningDate = DATEADD("D",(@dateloop*-1),@CurrentDate) SET @query1 = cast(DATEPART(YYYY, @RunningDate) AS varchar(4)) + cast(DATEPART(M, @RunningDate) AS varchar(2)) + cast(DATEPART(D, @RunningDate) AS varchar(2)) SET @query2 = @query2 + @query + @query1 + ' UNION ALL ' + CHAR(10) Select @DateLoop = @DateLoop + 1 END SELECT @Query2 = SUBSTRING( @Query2,1,LEN( @Query2)-11) EXEC sp_executeSQL @query2
Free Windows Admin Tool Kit Click here and download it now
May 24th, 2011 7:18am

Thank you Its working exactly as we expect ................
May 24th, 2011 7:50am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics