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 is the difference between a view and a stored procedure?
What is a transact-sql statement batch in ms sql server?
What are the database roles? : sql server security
what are the new features in SSRS?
Is the order of columns in the set clause important in ms sql server?
Explain how to integrate the ssrs reports in application?
What is difference between rownum and row_number?
Can you change the data type of a column in a table after the table has been created? If so, which command would you use?
What is clustered index
What is optimization and its types?
What command is used to delete a table from the database in the sql server and how?
What is a dbms wizard?
How to create new tables with "select ... Into" statements in ms sql server?
What is #table in sql server?
What is the maximum number of index per table?