Answer Posted / chris fauvel
--Both use the dateadd function provided by t-sql, I'm sure
oracle and others have similar functions
--this way is a little slower and costlier
select *
FROM sys.tables
where modify_date between dateadd(yy, -5, getdate() ) and
dateadd(yy, -2, getdate() )
--this way is faster and less costly, by not doing the same
--function for every row.
declare @now datetime
, @then datetime
select @now = convert(datetime, convert(varchar, getdate()))
, @then = dateadd(yy, -5, @now)
Select *
from sys.tables
where modify_date between @then and @now
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the different types of replication you can set up in sql server?
What are dml triggers and types of dml triggers?
What is factless fact table? : sql server analysis services, ssas
Define cursor locking
What are the differences between local and global temporary tables?
What is the maximum size of sql server database?
What is transaction server implicit?
How to get a list of columns using the "sys.columns" view in ms sql server?
How to access the inserted record of an event?
What is index, cluster index and nonclustered index?
Which are the important points to note when multilanguage data is stored in a table?
What is the boxing and unboxing concept in .net?
What is parameterized reports in ssrs ?
Can I disable or restrict ssrs export formats (rendering formats)?
What are commit and rollback in sql?