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
Which command is used for user defined error messages?
What is the native system stored procedure to execute a command against all databases?
What is the difference between deallocate cursor and close cursor?
Can foreign key be duplicate?
what is the system function to get current user's user id? : Sql server database administration
You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?
What is reference section?
What is the importance of a recovery model?
List down some advantages of sql stored procedure?
Why do we partition data?
What are acid properties of transaction?
System variable and temporary variables
How to encrypt data between dialogs?
What is onf in normalization form?
Ms sql server index?