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 is scan table/view and seek table/view when its occurs? : sql server database administration
What is the difference between deallocate cursor and close cursor?
Explain what is sql server english query?
What is index fragmentation in ms sql server?
How do triggers work?
What is triggers and stored procedures?
Determine when to use stored procedure to complete sql server tasks?
What is serializable?
hi i am working as a testengineer , so i want to no the backend data base connection can any one tell mwe in detail
What is the difference between ddl and dml?
What are translations and its use? : sql server analysis services, ssas
Mention the differences between substr and charindex in sql server.
What is raid? : SQL Server Architecture
How to list all user defined functions in the current database?
What do you mean by a Composite primary key?