tsql - Delete N oldest entries in table -
How to delete the oldest entries I'm limiting Sybase I have to write an archived procedure that accepts a number X And then leave only X latest entries in the table. For example: Say ID automatically grows I is short, this is the old entry.
ID text ========= ASD2 DSA3HJK4OUU I need a process that is implemented in this way Will be done .
Executed cleanup 2 and the result will be
id text =========3HJK Note: SQL Server syntax should work but
Remove from Pre> TableName where the ID (select the top ID from the order of the table name by ID)
If you want N to be a parameter, you create a statement You must do the string and execute it
Declare it @ kury varchar (4000) Tat @ Korea = 'Delete from the tablename' where id 'table of contents' id by ID (top +' N + ') ID in' set @ crew = @class + 'ID)' exec sp_executesql @query
Comments
Post a Comment