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
 SQL Server Development (2000)
 Massive DUMP!

Author  Topic 

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-24 : 15:54:00
Ok, what is the best practice to empty out a table at the end of the month of all records? IS there a trigger that can do it for me or what?

Thanks

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-24 : 15:59:32
You can create a new job with a single T-SQL task step, using the TRUNCATE TABLE command, and schedule the job to run once a month.

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-24 : 16:00:33
quote:

You can create a new job with a single T-SQL task step, using the TRUNCATE TABLE command, and schedule the job to run once a month.





Can u show me please?

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-09-24 : 16:31:29
In Enterprise Manager:

-Open the Management folder, then SQL Server Agent, then Jobs
-Choose create new job
-Give the job a name (General tab), then click on the Steps tab
-Click New, name the step, set the Type to Transact-SQL, set the database, and enter the following in the command box:

TRUNCATE TABLE myTable --change the table name as appropriate

-Click the Schedules tab, click New Schedule, set Recurring, and click Change. Set the time and date settings as appropriate. Save the job!

Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-25 : 07:39:15
quote:

In Enterprise Manager:

-Open the Management folder, then SQL Server Agent, then Jobs
-Choose create new job
-Give the job a name (General tab), then click on the Steps tab
-Click New, name the step, set the Type to Transact-SQL, set the database, and enter the following in the command box:

TRUNCATE TABLE myTable --change the table name as appropriate

-Click the Schedules tab, click New Schedule, set Recurring, and click Change. Set the time and date settings as appropriate. Save the job!





Very much appreciated! I see it. That is great.

What impact does a job have on the server resources? Does it bog it down during the execution of the job?

Thanks

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-09-25 : 07:49:04
The TRUNCATE TABLE command is a non-logged operation. With that in mind I would say the total impact will be around 47....

Jay White
{0}
Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-25 : 07:50:08
quote:

I would say the total impact will be around 47....

Jay White
{0}



sorry , what does that mean?

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-09-25 : 08:05:18
That was a joke...

There really isn't a concrete measure of its impact without knowing full details of your system. In fact, I don't believe 'bog down' has been defined. Lets just say the impact will be minimal. Better yet, try it in a dev environment and find out for yourself...

Jay White
{0}
Go to Top of Page

jesus4u
Posting Yak Master

204 Posts

Posted - 2002-09-25 : 08:05:51
LOL, thanks

Go to Top of Page
   

- Advertisement -