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 to recompile stored procedure at run time?
What is sparse columns of sql server 2008?
What is the difference between dataadapter and datareader?
What do you know about system database? : SQL Server Architecture
what is the difference between delete table and truncate table commands? : Sql server database administration
What is a periodical index?
What are the difficulties faced in cube development? : sql server analysis services, ssas
What is the difference between a check constraint and a rule?
Does table partitioning improve performance?
What is nolock?
How to implement one-to-one, one-to-many and many-to-many relationships while designing tables?
What are the requirements on sql server network connections?
What are the encryption mechanisms in sql server?
Is natural join and equi join same?
Is sql different from sql server?