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
What are the differences between stored procedure and the dynamic sql?
How to rebuild the master database?
What is the difference between MVC and Teir Architecher? Plz explain with Layyered Programming example...? Thanks
How to list all login names on the ms sql server?
How can I tell if sql server is 32 or 64 bit?
You have developed an application which uses many stored procedures and triggers to update various tables users ocassionally get locking problems which tool is best suited to help you diagnose the problem?
Is it possible to import data directly from t-sql commands without using sql server integration services? If so, what are the commands?
Explain what are the restrictions that views have to follow? : SQL Server Architecture
Explain the properties of sub-query in sql server?
What is temporary table in sql server? Why we use temp table?
What is the difference between index seek vs. Index scan?
How can you list all the table constraints in a database?
How to set database to be read_only in ms sql server?
 Explain what is sql override for a source taLle in a mapping?
Tell me extended events in sql server 2008?