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 multilevel indexing?
Explain about unique identifier data type in sql server?
When would you use a before or after trigger?
You want to implement the one-to-one relationship while designing tables. How would you do it?
Explain the properties of sub-query in sql server?
What is trigger and different types of Triggers?
What is sleeping status in sql server?
How to replace the Query Result 'Null Value' with a text ?
What are the main differences between #temp tables and @table variables and which one is preferred?
If user is owning any SQL Objects, can we drop that user
How to return the date part only from a sql server datetime datatype?
how do you determine the Load performance of any query in sql server {example how do u determine performance of a select stmnt which returns Dynamically many no of records ... some times 100,1000,10000 etc., }
Is the primary key column of a table an index in ms sql server?
What is explicit cursors?
What is stored in the mssqlsystemresource database? : sql server database administration