Showing posts with label store. Show all posts
Showing posts with label store. Show all posts

Thursday, March 29, 2012

Deleting records in the logfile

I have a database that is used to store a lot of data. We load the data on a
daily basis, several thousand records per day. The Log file is not needed,
so whats the best way to delete the records in it and reduce the size

Thanks

Derrick"Derrick King" <derrick.king@.bradford.gov.uk> wrote in message
news:c1l7ag$ejl$1@.newsreaderm1.core.theplanet.net. ..
> I have a database that is used to store a lot of data. We load the data on
a
> daily basis, several thousand records per day. The Log file is not needed,
> so whats the best way to delete the records in it and reduce the size
> Thanks
> Derrick

You don't mention which version of MSSQL you have, but assuming it's 2000,
then see "Recovery Models" in Books Online. If you don't need transaction
log backups, the easiest solution is probably to set the database to Simple
recovery mode, which will automatically recover log space if possible.

If that's not acceptable, then you can consider transaction log backups (if
you don't already do that), which will truncate the log. Truncating the log
frees up log space but does not make it physically smaller, so you may also
need to use DBCC SHRINKFILE - see "Shrinking Databases".

Simon

Sunday, February 19, 2012

Delete records each 15 day

Hi I have a table contains shopping cart info I want to delete the carts who
are 15 day old I have a coloumn that I store date in that ,
how can I delete records each 15 day and can I do it dynamicly?
Regards mahsaTry:
delete MyTable
where
TheDate < getdate () - 15
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
Hi I have a table contains shopping cart info I want to delete the carts who
are 15 day old I have a coloumn that I store date in that ,
how can I delete records each 15 day and can I do it dynamicly?
Regards mahsa|||Yes, write a stored procedure like this:
CREATE PROCEDURE dbo.clearCartData
AS
BEGIN
DELETE CartTable
WHERE [date column] < GETDATE()-15
END
GO
Then use SQL Agent to schedule the job to run once per day. (I assume you
want a rolling window, rather than delete a bunch of data every 15 days.)
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
> Hi I have a table contains shopping cart info I want to delete the carts
> who are 15 day old I have a coloumn that I store date in that ,
> how can I delete records each 15 day and can I do it dynamicly?
> Regards mahsa
>

Delete records each 15 day

Hi I have a table contains shopping cart info I want to delete the carts who are 15 day old I have a coloumn that I store date in that ,
how can I delete records each 15 day and can I do it dynamicly?
Regards mahsa
Try:
delete MyTable
where
TheDate < getdate () - 15
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
Hi I have a table contains shopping cart info I want to delete the carts who
are 15 day old I have a coloumn that I store date in that ,
how can I delete records each 15 day and can I do it dynamicly?
Regards mahsa
|||Yes, write a stored procedure like this:
CREATE PROCEDURE dbo.clearCartData
AS
BEGIN
DELETE CartTable
WHERE [date column] < GETDATE()-15
END
GO
Then use SQL Agent to schedule the job to run once per day. (I assume you
want a rolling window, rather than delete a bunch of data every 15 days.)
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
> Hi I have a table contains shopping cart info I want to delete the carts
> who are 15 day old I have a coloumn that I store date in that ,
> how can I delete records each 15 day and can I do it dynamicly?
> Regards mahsa
>

Delete records each 15 day

Hi I have a table contains shopping cart info I want to delete the carts who are 15 day old I have a coloumn that I store date in that
how can I delete records each 15 day and can I do it dynamicly
Regards mahsTry:
delete MyTable
where
TheDate < getdate () - 15
--
Tom
---
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
Hi I have a table contains shopping cart info I want to delete the carts who
are 15 day old I have a coloumn that I store date in that ,
how can I delete records each 15 day and can I do it dynamicly?
Regards mahsa|||Yes, write a stored procedure like this:
CREATE PROCEDURE dbo.clearCartData
AS
BEGIN
DELETE CartTable
WHERE [date column] < GETDATE()-15
END
GO
Then use SQL Agent to schedule the job to run once per day. (I assume you
want a rolling window, rather than delete a bunch of data every 15 days.)
--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
"mahsa" <anonymous@.discussions.microsoft.com> wrote in message
news:6AF95014-D4BE-4064-8E18-7B3FB89FA3E7@.microsoft.com...
> Hi I have a table contains shopping cart info I want to delete the carts
> who are 15 day old I have a coloumn that I store date in that ,
> how can I delete records each 15 day and can I do it dynamicly?
> Regards mahsa
>