I am trying to write a stored procedure, but mainly the sql, to delete all records older than 30 days. The extra part is that there are two tables, sharing a key, and I only want the records from the 2nd table deleted if the date value in the first table is older than 30 days from current date. The first table data should remain untouched.
This is a simple query to select data across the 2 tables. m.f_timestamp is the datetime type value I need to compare.
FROM dbo.t_message AS m,
dbo.t_attachements AS a