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
How global temporary tables are represented and its scope?
How efficient you are in oracle and SQL server?
What is oltp (online transaction processing)?
Can you leave a union at any time?
Which trace flags are enabled in sql server?
What is the command to change the recovery model?
Explain error handling in ssis?
What happens when the SQL Azure database reaches Max Size?
what is package and it uses and how can u call a package
What is the maximum number of index per table?
What are the approximate numeric data types?
When a primary key constraint is included in a table, what other constraints does this imply?
your sql server is running out of disk space. You notice that there are several large files with ldf extensions what are these files? : Sql server administration
Any one plz send me SQL Server Developer/DBA resume for 4 years experience
What is the difference between locking and multi-versioning?