Creating a job is one possibility, for examples see
Schedule a Job[
^] and
Create a Transact-SQL Job Step[
^] . However, keep in mind that this approach won't work with Express Editions since the SQL Agent is disabled for them.
But to give an alternative, are you sure you want to permanently delete the records? A much more common approach is to control the validity of a record. In other words if it's older than the 10 minutes, don't fetch it but let it still reside in the database. An easy way to achieve this is that you have a datetime field which has current datetime as default in a validity field and in your fetch you eliminate rows that are older than the desired amount of time.
Consider the following:
CREATE TABLE ValidityTest (
col1 varchar(100),
Created datetime DEFAULT GETDATE()
);
INSERT INTO ValidityTest (col1) VALUES ('Some row');
SELECT *
FROM ValidityTest
WHERE Created >= DATEADD(minute, -10, GETDATE())
if you want, you can make the query easier by creating a view to query from, for example
CREATE VIEW ValidRows AS
SELECT *
FROM ValidityTest
WHERE Created >= DATEADD(minute, -10, GETDATE());
Now you can easily query valid data
SELECT * FROM ValidRows;
If you like, you can run a cleanup delete every once in a while to remove records older than desiread amount of time (months for example) but as long as the space or speed isn't an issue, this isn't necessary.