Answer Posted / chris fauvel
--crap made a booboo
--corrected code here
--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
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 ? | 5 Yes | 0 No |
Post New Answer View All Answers
Write down the syntax and an example for create, rename and delete index?
How to find the list of fixed hard drive and free space on server?
What is the report builder?
What extended events?
What are the different types of lock modes in sql server 2000?
what is the system function to get current user's user id? : Sql server database administration
What is proper subset of candidate key?
How to insert data into an existing table?
What is unpivot?
what is the difference between Tabular and Matrix report?
What are the steps to take to improve performance of a poor performing query? : sql server database administration
How to create an inline table-valued function?
What is compression - row-level and page-level compression?
How do I port a number to sql server?
Which rendering formats are affected by the pagesize properties?