Friday, May 24, 2013

[SQL Server Data Warehousing] Archiving process through SSMS Sql jobs


Hi,


you need to create a Sql server agent job and in Step , Type= Transact SQL( TSQL).


paste your query in Command pane.


Sample:



Create table #T( id int, name varchar(50),LoadDate Date)
go
insert into #T values (1,'TESTNAME',GETDATE()-100)
go

insert into #T values (2,'TESTNAME2',GETDATE()-101)
go

insert into #T values (3,'TESTNAME3',GETDATE()-150)
go

insert into #T values (4,'TESTNAME4',GETDATE()-1)
go

insert into #T values (5,'TESTNAME5',GETDATE()-10)

select * From #T

--Insert into your Report Database
--insert into Dbo.DestinationTable
Select * from #T
WHERE LoadDate <= DATEADD(mm, -3, GETDATE())

Once the Job is created , you need to create Schedule for that. you can run the job every day, monthly or after each 3 months. 


If you are looking for different answer, please explain your requirement with example.


Thank you


Aamir



http://sqlage.blogspot.com/




.

social.technet.microsoft.com/Forums

No comments:

Post a Comment

Search This Blog