[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Stored Procedure

Posted on 2004-11-09
3
Medium Priority
?
311 Views
Last Modified: 2008-03-10
Hello
New to stored procedures.
How can i careate a stored procedure in SQL Server 2000 that will


1. Run every 3 hours automatically and
2. Take data from one table and dump it in other table
Example
TableOriginal ( empID,empName,empExt)
TableUpdated ( empID,empName,empExt)
Every hour the stored procedure should
a) Delete all the records in tableUpdated
b) fill tableUpdated will data from tableOriginal.
Thanks
0
Comment
Question by:svaria
3 Comments
 
LVL 6

Assisted Solution

by:Duane Lawrence
Duane Lawrence earned 400 total points
ID: 12533455

Create proc xxxxxx
as
  insert into table2name (col1,col2,col3)
  select co1,col2,col3 from table1
  --where conditions here
go


Then in enterprise manager you want to schedule a JOB to run stored proc xxxxxx.  This is pretty easy as you just have to point and click.

Duane
0
 
LVL 7

Accepted Solution

by:
wael_tahon earned 300 total points
ID: 12534096
Use this code:

Create procedure  DumpTables
as

-- Delete Dump data
Delete from DumpTable

-- Insert new Dump Data
insert into DumpTable(col1,col2,col3)
     Select co1,col2,col3 from SourceTable Where Condition=1

Go

then expand the management in the entrprise masnager and create a job to run this Procedure every 1 hour
0
 

Expert Comment

by:gurpreet006
ID: 14879667
i have a table testt1 with three columns.i want to create a stored procedure which will insert data in this table every one hour
can i have the complete source code for the stored procedure.(completely new to stored procedure)
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question