September 25, 2008 at 2:10 pm
This is the table DDL:
CREATE TABLE index_time
(
Starttime DATETIME,
ENDtime DATETIME,
Command VARCHAR(max),
Dumpdate datetime default getdate()
)
Please answer these questions:
1) I want to have data in this table(index_time) latest as 7 days (i,e,) data older than 7 days should be removed. How can i achieve this functionality.
2) Also I want to have another column in my table which says the duration for index reorg (i.e.) performing some calculations on stattime and endtime columns.
Please add any code if you can that would be helpful.
Thanks in advance.
September 26, 2008 at 12:12 am
FYI...
1) DELETE index_time
WHERE DumpDate < dateadd(dd, -7 getdate())
(or)
DELETE
WHERE
DumpDate <= DATEADD(day, -7, GETDATE())
2) DATEDIFF(millisecond, Startime, Endtime)
(or)
declare @start datetime, @end datetime
select @start = dateadd(mi, -12, dateadd(hh, -1, getdate())), @end = getdate()
select @start, @end, convert(varchar(8), (@end - @start), 108)
September 26, 2008 at 6:11 am
1) I want to have data in this table(index_time) latest as 7 days (i,e,) data older than 7 days should be removed. How can i achieve this functionality.
2) Also I want to have another column in my table which says the duration for index reorg (i.e.) performing some calculations on stattime and endtime columns.
1.Create a script that can be scheduled using scheduler which can be run at your convenient timings.
2.Use a computed column
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply