Stored Procedure

Posted on 2004-11-09
Last Modified: 2008-03-10
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
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.
Question by:svaria
    LVL 6

    Assisted Solution

    by:Duane Lawrence

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

    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.

    LVL 7

    Accepted Solution

    Use this code:

    Create procedure  DumpTables

    -- 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


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

    Expert Comment

    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)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    The steps for moving the system databases to a new location are documented in the following technical article: However sometimes after the moving process is finished, though SQL i…
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    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.

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now