SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


delete table


delete table

Author
Message
kumar99ms
kumar99ms
SSC Veteran
SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)

Group: General Forum Members
Points: 262 Visits: 550
Query to delete, all the records from a table before half an hour,…



Delete * from table where condition=100 and …..what we have write here…for time…

Regards,
Dugi
Dugi
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4586 Visits: 3511
no you can not do such a thing... you should save the script for deleting also with parameter that identify the condition and after that you will do schedule the job to do it for example after 30 min!

============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Johannes Fourie
Johannes Fourie
SSC Veteran
SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)

Group: General Forum Members
Points: 288 Visits: 230
Do you have a DATETIME column on the table? You would need it to delete rows older than 30 minutes. To do that you can use the DATEADD function in your where clause.

DELETE FROM dbo.YourTable WHERE Condition=100 AND YourTimeColumn < DATEADD(MINUTE, -30, GETDATE())
arjun.tewari
arjun.tewari
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 186
kumar99ms (8/20/2008)
Query to delete, all the records from a table before half an hour,…



Delete * from table where condition=100 and …..what we have write here…for time…

Regards,


I am afraid your question is not clear. What do you want? You want to delete all the records older than 30 mins or you want the delete statement should be fired after 30 mins?
Dugi
Dugi
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4586 Visits: 3511
Ok the ideas are here and if you want to clearly solution you must post the table definition and some sample data just to do the things correct!

============================================================
SELECT YOUR PROBLEM FROM SSC.com WHERE PROBLEM DESCRIPTION =
http://www.sqlservercentral.com/articles/Best+Practices/61537/
kumar99ms
kumar99ms
SSC Veteran
SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)SSC Veteran (262 reputation)

Group: General Forum Members
Points: 262 Visits: 550
hi every body

Thanks u for your effor

I want a query for delete every half an hour.

my condition is i am not schedule an job for this i am not use any Truncate also

Could plz any query using sysdate time or datetime for this plz help me
arjun.tewari
arjun.tewari
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 186
you can not do this using SQL. You will have to either schedule a job to do this or create a Windows Service which will fire the delete query every half-an-hour
Johannes Fourie
Johannes Fourie
SSC Veteran
SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)SSC Veteran (288 reputation)

Group: General Forum Members
Points: 288 Visits: 230
Another option would be to do the delete on an insert trigger, it would add additional overhead on the table, but if the table does not have too much activity then it should be fine. So the table with the trigger would constantly maintain itself. On the one hand it creates additional overhead, but the deletes will be done over smaller data sets because it may be executed more frequently, so it may even out.

You would still need a column that has the creation time of each record.
arjun.tewari
arjun.tewari
SSC Veteran
SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)SSC Veteran (235 reputation)

Group: General Forum Members
Points: 235 Visits: 186
Johannes Fourie (8/20/2008)
Another option would be to do the delete on an insert trigger, it would add additional overhead on the table, but if the table does not have too much activity then it should be fine. So the table with the trigger would constantly maintain itself. On the one hand it creates additional overhead, but the deletes will be done over smaller data sets because it may be executed more frequently, so it may even out.

You would still need a column that has the creation time of each record.


Hey Johannes
This fella wants to remove all the data from after every thirty minute. After every thirty minute, a query should execute and remove all the data from the table.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search