Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 procedure?

Author  Topic 

voidmain
Starting Member

6 Posts

Posted - 2006-02-19 : 04:11:18

how to create a procedure to take out certain data and drop into another table? I want to get the latest data depending on #date


thankx,

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-19 : 05:41:54
[code]create procedure your_sp
as
begin
insert into anothertable(col1, col2, col3, col4)
select cola, colb, colc, cold
from certaintable
where somedatecolumn = dateadd(day, -7, getdate()) -- 7 days from today
end[/code]

----------------------------------
'KH'

Time is always against us
Go to Top of Page

voidmain
Starting Member

6 Posts

Posted - 2006-02-19 : 06:16:34
thank you, khtan.
Go to Top of Page

voidmain
Starting Member

6 Posts

Posted - 2006-02-19 : 09:33:50

Another question.

How do i automate execution of stored procedures??? For eg, run everytime a DTS package runs/or at a particular interval ?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-02-19 : 09:38:06
You can scheduled the stored procedure via Enterprise Manager - Management - SQL Server Agent - Jobs - New Jobs. Under the step tab page, specify TSQL and your stored procedure under command.

----------------------------------
'KH'

Time is always against us
Go to Top of Page
   

- Advertisement -