Stored proc to delete 6 days old data
Here is my stored proc
ALTER procedure [dbo].[mtk_sp_Deletion]as
begin
delete from tbl1
where DateModified< getdate() - 6
delete tbl2
where DateModified < getdate() - 6
delete tbl3
where DateModified < getdate() - 6
end
RIGHT NOW I just hard code the value "6" but I want to achieve like read the text file (the text file contains开发者_运维问答 this value eg: 6 or 10 or 12), and get the value pass it here to delete.
Please some one help me how to achieve this
Thanks in advance
Pass the value as a parameter:
ALTER procedure [dbo].[mtk_sp_Deletion](
@nDays int = 6
)
as
begin
delete from tbl1
where DateModified< getdate() - @nDays
delete tbl2
where DateModified < getdate() - @nDays
delete tbl3
where DateModified < getdate() - @nDays
end
If you want to read that value from a textfile, do a search on SO and you will get lots of answers, e.g.: How to read in a text file from a stored procedure
精彩评论