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 log shipping? Can we do logshipping with SQL Server 7.0 - Logshipping is a new feature of SQL Server 2000. We should have two SQL Server - Enterprise Editions. From Enterprise Manager we can configure the logshipping. In logshipping the transactional log file from one server is automatically updated into the backup database on the other server. If one server fails, the other server will have the same db and we can use this as the DR (disaster recovery) plan.
How do you migrate data from mssql server to azure?
If a stored procedure is taking a table data type, how it looks?
What is the full form of ddl?
What are the different acid properties?
Explain the truncate command? : SQL Server Architecture
What is de-normalization and what are some of the examples of it?
Why truncate is ddl?
Define compound operators?
How do I create an extended event in sql server?
Explain Geography datatype in SQL Server
What is a trace frag?
Can an entity have two primary keys?
Explain some stored procedure creating best practices or guidelines?
What is used to replicate sessions between instances in coldfusion clusters?